Skip to:
Content

bbPress.org

Changeset 6120


Ignore:
Timestamp:
11/09/2016 10:53:16 PM (8 years ago)
Author:
johnjamesjacoby
Message:

Roles: Fix infinite loops from load order changes in WordPress 4.7.

  • Do not translate "role names" which are actually role IDs
  • Add dummy function so literal role names are part of the pomo dictionary
  • Introduce common/locale.php for future localization code
  • Introduce bbp_translate_user_role() to help with outputting literal role names in the proper language

See #3017. 2.5 branch (for 2.5.11)

Location:
branches/2.5
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/2.5/bbpress.php

    r6064 r6120  
    301301        require( $this->includes_dir . 'common/functions.php'     );
    302302        require( $this->includes_dir . 'common/formatting.php'    );
     303        require( $this->includes_dir . 'common/locale.php'        );
    303304        require( $this->includes_dir . 'common/template.php'      );
    304305        require( $this->includes_dir . 'common/widgets.php'       );
  • branches/2.5/includes/admin/settings.php

    r5366 r6120  
    522522        <?php foreach ( bbp_get_dynamic_roles() as $role => $details ) : ?>
    523523
    524             <option <?php selected( $default_role, $role ); ?> value="<?php echo esc_attr( $role ); ?>"><?php echo translate_user_role( $details['name'] ); ?></option>
     524            <option <?php selected( $default_role, $role ); ?> value="<?php echo esc_attr( $role ); ?>"><?php echo bbp_translate_user_role( $details['name'] ); ?></option>
    525525
    526526        <?php endforeach; ?>
  • branches/2.5/includes/admin/users.php

    r5629 r6120  
    104104                            <?php foreach ( $dynamic_roles as $role => $details ) : ?>
    105105
    106                                 <option <?php selected( $user_role, $role ); ?> value="<?php echo esc_attr( $role ); ?>"><?php echo translate_user_role( $details['name'] ); ?></option>
     106                                <option <?php selected( $user_role, $role ); ?> value="<?php echo esc_attr( $role ); ?>"><?php echo bbp_translate_user_role( $details['name'] ); ?></option>
    107107
    108108                            <?php endforeach; ?>
     
    140140            <option value=''><?php esc_html_e( 'Change forum role to&hellip;', 'bbpress' ) ?></option>
    141141            <?php foreach ( $dynamic_roles as $role => $details ) : ?>
    142                 <option value="<?php echo esc_attr( $role ); ?>"><?php echo translate_user_role( $details['name'] ); ?></option>
     142                <option value="<?php echo esc_attr( $role ); ?>"><?php echo bbp_translate_user_role( $details['name'] ); ?></option>
    143143            <?php endforeach; ?>
    144144        </select><?php submit_button( __( 'Change', 'bbpress' ), 'secondary', 'bbp-change-role', false );
     
    244244            if ( ! empty( $user_role ) ) {
    245245                $roles  = bbp_get_dynamic_roles();
    246                 $retval = translate_user_role( $roles[$user_role]['name'] );
     246                $retval = bbp_translate_user_role( $roles[$user_role]['name'] );
    247247            }
    248248        }
  • branches/2.5/includes/core/capabilities.php

    r5064 r6120  
    378378        // Keymaster
    379379        bbp_get_keymaster_role() => array(
    380             'name'         => __( 'Keymaster', 'bbpress' ),
     380            'name'         => 'Keymaster',
    381381            'capabilities' => bbp_get_caps_for_role( bbp_get_keymaster_role() )
    382382        ),
     
    384384        // Moderator
    385385        bbp_get_moderator_role() => array(
    386             'name'         => __( 'Moderator', 'bbpress' ),
     386            'name'         => 'Moderator',
    387387            'capabilities' => bbp_get_caps_for_role( bbp_get_moderator_role() )
    388388        ),
     
    390390        // Participant
    391391        bbp_get_participant_role() => array(
    392             'name'         => __( 'Participant', 'bbpress' ),
     392            'name'         => 'Participant',
    393393            'capabilities' => bbp_get_caps_for_role( bbp_get_participant_role() )
    394394        ),
     
    396396        // Spectator
    397397        bbp_get_spectator_role() => array(
    398             'name'         => __( 'Spectator', 'bbpress' ),
     398            'name'         => 'Spectator',
    399399            'capabilities' => bbp_get_caps_for_role( bbp_get_spectator_role() )
    400400        ),
     
    402402        // Blocked
    403403        bbp_get_blocked_role() => array(
    404             'name'         => __( 'Blocked', 'bbpress' ),
     404            'name'         => 'Blocked',
    405405            'capabilities' => bbp_get_caps_for_role( bbp_get_blocked_role() )
    406406        )
  • branches/2.5/includes/core/sub-actions.php

    r5023 r6120  
    137137 *
    138138 * @since bbPress (r2695)
    139  * @uses did_action() To make sure the user isn't loaded out of order
    140139 * @uses do_action() Calls 'bbp_setup_current_user'
    141140 */
    142141function bbp_setup_current_user() {
    143 
    144     // If the current user is being setup before the "init" action has fired,
    145     // strange (and difficult to debug) role/capability issues will occur.
    146     if ( ! did_action( 'after_setup_theme' ) ) {
    147         _doing_it_wrong( __FUNCTION__, __( 'The current user is being initialized without using $wp->init().', 'bbpress' ), '2.3' );
    148     }
    149 
    150142    do_action( 'bbp_setup_current_user' );
    151143}
  • branches/2.5/includes/users/template.php

    r6063 r6120  
    12571257        <?php foreach ( $blog_roles as $role => $details ) : ?>
    12581258
    1259             <option <?php selected( $user_role, $role ); ?> value="<?php echo esc_attr( $role ); ?>"><?php echo translate_user_role( $details['name'] ); ?></option>
     1259            <option <?php selected( $user_role, $role ); ?> value="<?php echo esc_attr( $role ); ?>"><?php echo bbp_translate_user_role( $details['name'] ); ?></option>
    12601260
    12611261        <?php endforeach; ?>
     
    12921292        <?php foreach ( $dynamic_roles as $role => $details ) : ?>
    12931293
    1294             <option <?php selected( $user_role, $role ); ?> value="<?php echo esc_attr( $role ); ?>"><?php echo translate_user_role( $details['name'] ); ?></option>
     1294            <option <?php selected( $user_role, $role ); ?> value="<?php echo esc_attr( $role ); ?>"><?php echo bbp_translate_user_role( $details['name'] ); ?></option>
    12951295
    12961296        <?php endforeach; ?>
Note: See TracChangeset for help on using the changeset viewer.