WordPress.org

Plugin Directory

Changeset 548399


Ignore:
Timestamp:
05/24/12 06:28:27 (2 years ago)
Author:
cnorris23
Message:
  • Code simplification and cleanup
  • A tiny bit more work on auto-updating nicename
File:
1 edited

Legend:

Unmodified
Added
Removed
  • edit-author-slug/trunk/includes/admin-functions.php

    r546855 r548399  
    3434 
    3535    $options = array(); 
    36     $options['ba_eas_username'] = sanitize_title( $user->user_login ); 
    37     $options['ba_eas_nickname'] = sanitize_title( $user->nickname ); 
     36    $options['username'] = sanitize_title( $user->user_login ); 
     37    $options['nickname'] = sanitize_title( $user->nickname ); 
    3838 
    3939    if ( !empty( $user->first_name ) ) 
    40         $options['ba_eas_firstname'] = sanitize_title( $user->first_name ); 
     40        $options['firstname'] = sanitize_title( $user->first_name ); 
    4141 
    4242    if ( !empty( $user->last_name ) ) 
    43         $options['ba_eas_lastname'] = sanitize_title( $user->last_name ); 
     43        $options['lastname'] = sanitize_title( $user->last_name ); 
    4444 
    4545    if ( !empty( $user->first_name ) && !empty( $user->last_name ) ) { 
    46         $options['ba_eas_firstname-lastname'] = sanitize_title( $user->first_name  . ' ' . $user->last_name ); 
    47         $options['ba_eas_lastname-firstname'] = sanitize_title( $user->last_name . ' ' . $user->first_name ); 
     46        $options['firstname-lastname'] = sanitize_title( $user->first_name  . ' ' . $user->last_name ); 
     47        $options['lastname-firstname'] = sanitize_title( $user->last_name . ' ' . $user->first_name ); 
    4848    } 
    4949 
    50     $options['ba_eas_other'] = $nicename; 
    51  
    52     $options = (array) $options; 
     50    $options['other'] = $nicename; 
     51 
     52    $options = (array) apply_filters( 'ba_eas_show_user_nicename_options_list', $options ); 
    5353    $options = array_map( 'trim', $options ); 
    5454    $options = array_unique( $options ); 
     
    6363                <select id="ba_eas_author_slug_select" name="ba_eas_author_slug_select"> 
    6464                <?php foreach ( (array) $options as $id => $item ) { ?> 
    65                     <option id="<?php esc_attr_e( $id ); ?>" value="<?php esc_attr_e( $item ); ?>"<?php selected( $nicename, $item ); ?>><?php esc_attr_e( str_replace( 'ba_eas_', '', $id ) ); ?></option> 
     65                    <option id="<?php esc_attr_e( $id ); ?>" value="<?php esc_attr_e( $item ); ?>"<?php selected( $nicename, $item ); ?>><?php esc_attr_e( $id ); ?></option> 
    6666                <?php } ?> 
    6767                </select> 
     
    197197 * @param int $user_id User id 
    198198 * 
     199 * @uses get_userdata() To get the user object 
    199200 * @uses get_option() To get the default nicename structure 
    200201 */ 
    201202function ba_eas_auto_update_user_nicename( $user_id ) { 
     203    // Bail if no user_id 
     204    if ( empty( $user_id ) ) 
     205        return; 
     206 
     207    // Get WP_User object 
     208    $user = get_userdata( $user_id ); 
     209 
     210    // Double check we're still good 
     211    if ( !is_object( $user ) || empty( $user->id ) ) 
     212        return; 
     213 
    202214    // Get the default nicename structure 
    203215    $structure = get_option( '_ba_eas_default_user_nicename', 'username' ); 
     216 
    204217} 
    205218 
     
    442455    $structure = get_option( '_ba_eas_default_user_nicename', 'username' ); 
    443456 
    444     $options = apply_filters( 'ba_eas_admin_setting_callback_default_user_nicename_list', array( 
     457    $options = apply_filters( 'ba_eas_default_user_nicename_options_list', array( 
    445458        'username'  => 'Default (Username)', 
    446459        'nickname'  => 'Nickname', 
Note: See TracChangeset for help on using the changeset viewer.