Changeset 28740
- Timestamp:
- 06/11/2014 06:20:57 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/user.php
r28722 r28740 1644 1644 $user_nicename = $userdata['user_nicename']; 1645 1645 } 1646 1647 // Store values to save in user meta. 1648 $meta = array(); 1649 1646 1650 /** 1647 1651 * Filter a user's nicename before the user is created or updated. … … 1653 1657 $user_nicename = apply_filters( 'pre_user_nicename', $user_nicename ); 1654 1658 1655 $ user_url = empty( $userdata['user_url'] ) ? '' : $userdata['user_url'];1659 $raw_user_url = empty( $userdata['user_url'] ) ? '' : $userdata['user_url']; 1656 1660 1657 1661 /** … … 1660 1664 * @since 2.0.3 1661 1665 * 1662 * @param string $ user_url The user's URL.1663 */ 1664 $user_url = apply_filters( 'pre_user_url', $ user_url );1665 1666 $ user_email = empty( $userdata['user_email'] ) ? '' : $userdata['user_email'];1666 * @param string $raw_user_url The user's URL. 1667 */ 1668 $user_url = apply_filters( 'pre_user_url', $raw_user_url ); 1669 1670 $raw_user_email = empty( $userdata['user_email'] ) ? '' : $userdata['user_email']; 1667 1671 1668 1672 /** … … 1671 1675 * @since 2.0.3 1672 1676 * 1673 * @param string $ user_email The user's email.1674 */ 1675 $user_email = apply_filters( 'pre_user_email', $ user_email );1677 * @param string $raw_user_email The user's email. 1678 */ 1679 $user_email = apply_filters( 'pre_user_email', $raw_user_email ); 1676 1680 1677 1681 if ( ! $update && ! defined( 'WP_IMPORTING' ) && email_exists( $user_email ) ) { … … 1679 1683 } 1680 1684 $nickname = empty( $userdata['nickname'] ) ? $user_login : $userdata['nickname']; 1685 1681 1686 /** 1682 1687 * Filter a user's nickname before the user is created or updated. … … 1686 1691 * @param string $nickname The user's nickname. 1687 1692 */ 1688 $ nickname= apply_filters( 'pre_user_nickname', $nickname );1693 $meta['nickname'] = apply_filters( 'pre_user_nickname', $nickname ); 1689 1694 1690 1695 $first_name = empty( $userdata['first_name'] ) ? '' : $userdata['first_name']; … … 1697 1702 * @param string $first_name The user's first name. 1698 1703 */ 1699 $ first_name= apply_filters( 'pre_user_first_name', $first_name );1704 $meta['first_name'] = apply_filters( 'pre_user_first_name', $first_name ); 1700 1705 1701 1706 $last_name = empty( $userdata['last_name'] ) ? '' : $userdata['last_name']; … … 1708 1713 * @param string $last_name The user's last name. 1709 1714 */ 1710 $ last_name= apply_filters( 'pre_user_last_name', $last_name );1715 $meta['last_name'] = apply_filters( 'pre_user_last_name', $last_name ); 1711 1716 1712 1717 if ( empty( $userdata['display_name'] ) ) { 1713 1718 if ( $update ) { 1714 1719 $display_name = $user_login; 1715 } elseif ( $ first_name && $last_name) {1720 } elseif ( $meta['first_name'] && $meta['last_name'] ) { 1716 1721 /* translators: 1: first name, 2: last name */ 1717 $display_name = sprintf( _x( '%1$s %2$s', 'Display name based on first name and last name' ), $ first_name, $last_name);1718 } elseif ( $ first_name) {1719 $display_name = $ first_name;1720 } elseif ( $ last_name) {1721 $display_name = $ last_name;1722 $display_name = sprintf( _x( '%1$s %2$s', 'Display name based on first name and last name' ), $meta['first_name'], $meta['last_name'] ); 1723 } elseif ( $meta['first_name'] ) { 1724 $display_name = $meta['first_name']; 1725 } elseif ( $meta['last_name'] ) { 1726 $display_name = $meta['last_name']; 1722 1727 } else { 1723 1728 $display_name = $user_login; … … 1745 1750 * @param string $description The user's description. 1746 1751 */ 1747 $ description= apply_filters( 'pre_user_description', $description );1748 1749 $ rich_editing= empty( $userdata['rich_editing'] ) ? 'true' : $userdata['rich_editing'];1750 1751 $ comment_shortcuts= empty( $userdata['comment_shortcuts'] ) ? 'false' : $userdata['comment_shortcuts'];1752 $meta['description'] = apply_filters( 'pre_user_description', $description ); 1753 1754 $meta['rich_editing'] = empty( $userdata['rich_editing'] ) ? 'true' : $userdata['rich_editing']; 1755 1756 $meta['comment_shortcuts'] = empty( $userdata['comment_shortcuts'] ) ? 'false' : $userdata['comment_shortcuts']; 1752 1757 1753 1758 $admin_color = empty( $userdata['admin_color'] ) ? 'fresh' : $userdata['admin_color']; 1754 $ admin_color= preg_replace( '|[^a-z0-9 _.\-@]|i', '', $admin_color );1755 1756 $ use_ssl= empty( $userdata['use_ssl'] ) ? 0 : $userdata['use_ssl'];1759 $meta['admin_color'] = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $admin_color ); 1760 1761 $meta['use_ssl'] = empty( $userdata['use_ssl'] ) ? 0 : $userdata['use_ssl']; 1757 1762 1758 1763 $user_registered = empty( $userdata['user_registered'] ) ? gmdate( 'Y-m-d H:i:s' ) : $userdata['user_registered']; 1759 1764 1760 $ show_admin_bar_front= empty( $userdata['show_admin_bar_front'] ) ? 'true' : $userdata['show_admin_bar_front'];1765 $meta['show_admin_bar_front'] = empty( $userdata['show_admin_bar_front'] ) ? 'true' : $userdata['show_admin_bar_front']; 1761 1766 1762 1767 $user_nicename_check = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1" , $user_nicename, $user_login)); … … 1772 1777 } 1773 1778 1774 $ data= compact( 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' );1775 $data = wp_unslash( $ data);1779 $compacted = compact( 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' ); 1780 $data = wp_unslash( $compacted ); 1776 1781 1777 1782 if ( $update ) { … … 1785 1790 $user = new WP_User( $user_id ); 1786 1791 1787 foreach ( _get_additional_user_keys( $user ) as $key ) { 1788 if ( isset( $$key ) ) { 1789 update_user_meta( $user_id, $key, $$key ); 1792 // Update user meta. 1793 foreach ( $meta as $key => $value ) { 1794 update_user_meta( $user_id, $key, $value ); 1795 } 1796 1797 foreach ( wp_get_user_contact_methods( $user ) as $key => $value ) { 1798 if ( isset( $userdata[ $key ] ) ) { 1799 update_user_meta( $user_id, $key, $userdata[ $key ] ); 1790 1800 } 1791 1801 }
Note: See TracChangeset
for help on using the changeset viewer.