Ticket #42725: gender-to-user-profile.diff
| File gender-to-user-profile.diff, 5.0 KB (added by , 9 years ago) |
|---|
-
src/wp-includes/user.php
435 435 } 436 436 437 437 /** 438 * Get the current user's gender 439 * 440 * @since MU (5.0.0) 441 * 442 * @return string The current user's gender, or 'unknown' if no user is logged in, or unset. 443 */ 444 function get_current_user_gender() { 445 if ( ! function_exists( 'wp_get_current_user' ) ) 446 return 'unknown'; 447 448 $user = wp_get_current_user(); 449 return ( isset( $user->gender ) ? $user->gender : 'unknown' ); 450 } 451 452 /** 438 453 * Retrieve user option that can be either per Site or per Network. 439 454 * 440 455 * If the user ID is not given, then the current user will be used instead. If … … 1414 1429 * to build the second part of the user's display name 1415 1430 * if `$display_name` is not specified. 1416 1431 * @type string $description The user's biographical description. 1432 * @type string $gender The user's chosen gender. 1417 1433 * @type string|bool $rich_editing Whether to enable the rich-editor for the user. 1418 1434 * False if not empty. 1419 1435 * @type string|bool $syntax_highlighting Whether to enable the rich code editor for the user. … … 1629 1645 */ 1630 1646 $meta['description'] = apply_filters( 'pre_user_description', $description ); 1631 1647 1648 $meta['gender'] = empty( $userdata['gender'] ) ? 'unknown' : $userdata['gender']; 1649 1632 1650 $meta['rich_editing'] = empty( $userdata['rich_editing'] ) ? 'true' : $userdata['rich_editing']; 1633 1651 1634 1652 $meta['syntax_highlighting'] = empty( $userdata['syntax_highlighting'] ) ? 'true' : $userdata['syntax_highlighting']; … … 1719 1737 * @type string $first_name The user's first name. 1720 1738 * @type string $last_name The user's last name. 1721 1739 * @type string $description The user's description. 1740 * @type string $gender The user's gender. 1722 1741 * @type bool $rich_editing Whether to enable the rich-editor for the user. False if not empty. 1723 1742 * @type bool $syntax_highlighting Whether to enable the rich code editor for the user. False if not empty. 1724 1743 * @type bool $comment_shortcuts Whether to enable keyboard shortcuts for the user. Default false. -
src/wp-includes/class-wp-user.php
32 32 * @property string $spam 33 33 * @property string $deleted 34 34 * @property string $locale 35 * @property string $gender 35 36 * @property string $rich_editing 36 37 * @property string $syntax_highlighting 37 38 */ -
src/wp-admin/includes/user.php
85 85 if ( isset( $_POST['description'] ) ) 86 86 $user->description = trim( $_POST['description'] ); 87 87 88 if ( isset( $_POST['gender'] ) ) { 89 $user->gender = in_array( $_POST['gender'], array( 'unknown', 'female', 'male' ), true ) ? $_POST['gender'] : 'unknown'; 90 } 91 88 92 foreach ( wp_get_user_contact_methods( $user ) as $method => $name ) { 89 93 if ( isset( $_POST[$method] )) 90 94 $user->$method = sanitize_text_field( $_POST[$method] ); -
src/wp-admin/user-edit.php
551 551 </tr> 552 552 <?php endif; ?> 553 553 554 <tr class="user-gender-wrap"> 555 <th><label for="gender"><?php _e( 'What pronoun do you prefer?' ); ?></label></th> 556 <td> 557 <p> 558 <?php 559 $gender = get_user_meta( $user_id, 'gender', true ); 560 if ( ! $gender ) { 561 $gender = 'unknown'; 562 } 563 ?> 564 <label><input name="gender" type="radio" value="female" <?php checked( 'female', $gender ); ?> /> <?php _e( 'Female: She published a new post.' ); ?></label><br /> 565 <label><input name="gender" type="radio" value="male" <?php checked( 'male', $gender ); ?> /> <?php _e( 'Male: He published a new post.' ); ?></label><br /> 566 <label><input name="gender" type="radio" value="unknown" <?php checked( 'unknown', $gender ); ?> /> <?php _e( 'Other/Unknown: They published a new post.' ); ?></label> 567 </p> 568 <p class="description"> 569 <?php _e( 'This preference will allow WordPress to address you and to mention you to others using the appropriate grammatical gender.'); ?><br /> 570 <?php _e( 'If "Other/Unknown" is chosen, WordPress will use gender-neutral words whenever possible.' ); ?> 571 </p> 572 </td> 573 </tr> 574 554 575 <?php 555 576 /** 556 577 * Filters the display of the password fields.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)