本文整理汇总了PHP中WP_User::back_compat_keys方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_User::back_compat_keys方法的具体用法?PHP WP_User::back_compat_keys怎么用?PHP WP_User::back_compat_keys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_User
的用法示例。
在下文中一共展示了WP_User::back_compat_keys方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Constructor
*
* Retrieves the userdata and passes it to {@link WP_User::init()}.
*
* @since 2.0.0
* @access public
*
* @param int|string $id User's ID
* @param string $name Optional. User's username
* @param int $blog_id Optional Blog ID, defaults to current blog.
* @return WP_User
*/
function __construct($id = 0, $name = '', $blog_id = '')
{
if (!isset(self::$back_compat_keys)) {
$prefix = $GLOBALS['wpdb']->prefix;
self::$back_compat_keys = array('user_firstname' => 'first_name', 'user_lastname' => 'last_name', 'user_description' => 'description', 'user_level' => $prefix . 'user_level', $prefix . 'usersettings' => $prefix . 'user-settings', $prefix . 'usersettingstime' => $prefix . 'user-settings-time');
}
if (!empty($id) && !is_numeric($id)) {
$name = $id;
$id = 0;
}
if ($id) {
$data = self::get_data_by('id', $id);
} else {
$data = self::get_data_by('login', $name);
}
if ($data) {
$this->init($data, $blog_id);
}
}
示例2: __construct
/**
* Constructor.
*
* Retrieves the userdata and passes it to WP_User::init().
*
* @since 2.0.0
* @access public
*
* @param int|string|stdClass|WP_User $id User's ID, a WP_User object, or a user object from the DB.
* @param string $name Optional. User's username
* @param int $blog_id Optional Site ID, defaults to current site.
*/
public function __construct($id = 0, $name = '', $blog_id = '')
{
$this->db = $GLOBALS['wpdb'];
if (!isset(self::$back_compat_keys)) {
$prefix = $this->db->prefix;
self::$back_compat_keys = array('user_firstname' => 'first_name', 'user_lastname' => 'last_name', 'user_description' => 'description', 'user_level' => $prefix . 'user_level', $prefix . 'usersettings' => $prefix . 'user-settings', $prefix . 'usersettingstime' => $prefix . 'user-settings-time');
}
if ($id instanceof WP_User) {
$this->init($id->data, $blog_id);
return;
} elseif (is_object($id)) {
$this->init($id, $blog_id);
return;
}
if (!empty($id) && !is_numeric($id)) {
$name = $id;
$id = 0;
}
if ($id) {
$data = self::get_data_by('id', $id);
} else {
$data = self::get_data_by('login', $name);
}
if ($data) {
$this->init($data, $blog_id);
} else {
$this->data = new stdClass();
}
}