Skip to:
Content

BuddyPress.org

Changeset 6448


Ignore:
Timestamp:
10/22/2012 08:00:13 AM (7 years ago)
Author:
johnjamesjacoby
Message:

Activate and Sign-up:

  • Resurrect bp_has_custom_activation_page() from 1.6 deprecation.
  • Use bp_has_custom_activation_page() similarly to bp_has_custom_signup_page().
  • Use static variable to prevent repeating logic multiple times per page load.
  • Add phpdoc blocks.
  • Use bp_locate_template() in bp_has_custom_activation_page() and bp_has_custom_signup_page() to more easily find whether a file exists in the correct location to provide template output.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/deprecated/1.6.php

    r6342 r6448  
    8080function bp_core_add_ajax_hook() {
    8181    _deprecated_function( __FUNCTION__, '1.6', 'No longer used' );
    82 }
    83 
    84 /**
    85  * Members functions
    86  */
    87 
    88 /**
    89  * @deprecated 1.6
    90  * @deprecated No longer used. Check for $bp->pages->activate->slug instead.
    91  */
    92 function bp_has_custom_activation_page() {
    93     _deprecated_function( __FUNCTION__, '1.6' );
    9482}
    9583
  • trunk/bp-members/bp-members-template.php

    r6404 r6448  
    108108     */
    109109    function bp_get_signup_slug() {
    110         global $bp;
     110        $bp = buddypress();
    111111
    112112        if ( !empty( $bp->pages->register->slug ) )
     
    967967/** Signup Form ***************************************************************/
    968968
     969/**
     970 * Do we have a working custom sign up page?
     971 *
     972 * @since BuddyPress (1.5)
     973 *
     974 * @uses bp_get_signup_slug() To make sure there is a slug assigned to the page
     975 * @uses bp_locate_template() To make sure a template exists to provide output
     976 * @return boolean True if page and template exist, false if not
     977 */
    969978function bp_has_custom_signup_page() {
    970     // if theme is not bp-default, theme compat is on
    971     // theme compat already bundles its own templates
    972     if ( ! bp_is_theme_bp_default() )
    973         return true;
    974 
    975     // look in parent / child theme for custom registration templates
    976     if ( locate_template( array( 'register.php' ), false ) || locate_template( array( '/registration/register.php' ), false ) )
    977         return true;
    978 
    979     return false;
     979    static $has_page = false;
     980
     981    if ( empty( $has_page ) )
     982        $has_page = bp_get_signup_slug() && bp_locate_template( array( 'registration/register.php', 'members/register.php', 'register.php' ), false );
     983
     984    return (bool) $has_page;
    980985}
    981986
     
    10011006    }
    10021007
     1008/**
     1009 * Do we have a working custom activation page?
     1010 *
     1011 * @since BuddyPress (1.5)
     1012 *
     1013 * @uses bp_get_activate_slug() To make sure there is a slug assigned to the page
     1014 * @uses bp_locate_template() To make sure a template exists to provide output
     1015 * @return boolean True if page and template exist, false if not
     1016 */
     1017function bp_has_custom_activation_page() {
     1018    static $has_page = false;
     1019   
     1020    if ( empty( $has_page ) )
     1021        $has_page = bp_get_activate_slug() && bp_locate_template( array( 'registration/activate.php', 'members/activate.php', 'activate.php' ), false );
     1022
     1023    return (bool) $has_page;
     1024}
     1025
    10031026function bp_activation_page() {
    10041027    echo bp_get_activation_page();
    10051028}
    10061029    function bp_get_activation_page() {
    1007         global $bp;
    1008 
    1009         // Check the global directly to make sure the WP page exists in $bp->pages
    1010         if ( !empty( $bp->pages->activate->slug ) )
    1011             $page = trailingslashit( bp_get_root_domain() . '/' . $bp->pages->activate->slug );
    1012         else
     1030        if ( bp_has_custom_activation_page() ) {
     1031            $page = trailingslashit( bp_get_root_domain() . '/' . bp_get_activate_slug() );
     1032        } else {
    10131033            $page = trailingslashit( bp_get_root_domain() ) . 'wp-activate.php';
     1034        }
    10141035
    10151036        return apply_filters( 'bp_get_activation_page', $page );
Note: See TracChangeset for help on using the changeset viewer.