In PHP 5.0.0, `is_a()` became deprecated in favour of the `instanceof` operator. Calling `is_a()` would result in an `E_STRICT` warning.

In PHP 5.3.0, `is_a()` is no longer deprecated, and will therefore no longer throw `E_STRICT` warnings.

To avoid warnings in PHP < 5.3.0, convert all `is_a()` calls to `$var instanceof WP_Class` calls.

`instanceof` does not throw any error if the variable being tested is not an object, it simply returns `false`.

Props markoheijnen, wonderboymusic.
Fixes #25672.

Built from https://develop.svn.wordpress.org/trunk@31188


git-svn-id: http://core.svn.wordpress.org/trunk@31169 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-01-16 01:06:24 +00:00
parent 6704875855
commit fe6b5983df
25 changed files with 77 additions and 69 deletions

View File

@ -339,8 +339,9 @@ class WP_Users_List_Table extends WP_List_Table {
public function single_row( $user_object, $style = '', $role = '', $numposts = 0 ) {
global $wp_roles;
if ( !( is_object( $user_object ) && is_a( $user_object, 'WP_User' ) ) )
if ( ! ( $user_object instanceof WP_User ) ) {
$user_object = get_userdata( (int) $user_object );
}
$user_object->filter = 'display';
$email = $user_object->user_email;

View File

@ -374,8 +374,9 @@ final class WP_Screen {
*/
public static function get( $hook_name = '' ) {
if ( is_a( $hook_name, 'WP_Screen' ) )
if ( $hook_name instanceof WP_Screen ) {
return $hook_name;
}
$post_type = $taxonomy = null;
$in_admin = false;

View File

@ -176,7 +176,7 @@ function wp_terms_checklist( $post_id = 0, $args = array() ) {
$r = wp_parse_args( $params, $defaults );
if ( empty( $r['walker'] ) || ! is_a( $r['walker'], 'Walker' ) ) {
if ( empty( $r['walker'] ) || ! ( $r['walker'] instanceof Walker ) ) {
$walker = new Walker_Category_Checklist;
} else {
$walker = $r['walker'];

View File

@ -149,8 +149,9 @@ function get_theme_update_available( $theme ) {
if ( !isset($themes_update) )
$themes_update = get_site_transient('update_themes');
if ( ! is_a( $theme, 'WP_Theme' ) )
if ( ! ( $theme instanceof WP_Theme ) ) {
return false;
}
$stylesheet = $theme->get_stylesheet();

View File

@ -520,7 +520,7 @@ class WP_User {
);
}
if ( is_a( $id, 'WP_User' ) ) {
if ( $id instanceof WP_User ) {
$this->init( $id->data, $blog_id );
return;
} elseif ( is_object( $id ) ) {

View File

@ -882,11 +882,11 @@ function _wp_object_count_sort_cb( $a, $b ) {
function walk_category_tree() {
$args = func_get_args();
// the user's options are the third parameter
if ( empty($args[2]['walker']) || !is_a($args[2]['walker'], 'Walker') )
if ( empty( $args[2]['walker'] ) || ! ( $args[2]['walker'] instanceof Walker ) ) {
$walker = new Walker_Category;
else
} else {
$walker = $args[2]['walker'];
}
return call_user_func_array(array( &$walker, 'walk' ), $args );
}

View File

@ -37,8 +37,9 @@ class WP_Feed_Cache_Transient {
}
public function save($data) {
if ( is_a($data, 'SimplePie') )
if ( $data instanceof SimplePie ) {
$data = $data->data;
}
set_transient($this->name, $data, $this->lifetime);
set_transient($this->mod_name, time(), $this->lifetime);

View File

@ -695,11 +695,11 @@ final class WP_Customize_Manager {
* constructor.
*/
public function add_setting( $id, $args = array() ) {
if ( is_a( $id, 'WP_Customize_Setting' ) )
if ( $id instanceof WP_Customize_Setting ) {
$setting = $id;
else
} else {
$setting = new WP_Customize_Setting( $this, $id, $args );
}
$this->settings[ $setting->id ] = $setting;
}
@ -737,10 +737,9 @@ final class WP_Customize_Manager {
* @param array $args Optional. Panel arguments. Default empty array.
*/
public function add_panel( $id, $args = array() ) {
if ( is_a( $id, 'WP_Customize_Panel' ) ) {
if ( $id instanceof WP_Customize_Panel ) {
$panel = $id;
}
else {
} else {
$panel = new WP_Customize_Panel( $this, $id, $args );
}
@ -783,11 +782,11 @@ final class WP_Customize_Manager {
* @param array $args Section arguments.
*/
public function add_section( $id, $args = array() ) {
if ( is_a( $id, 'WP_Customize_Section' ) )
if ( $id instanceof WP_Customize_Section ) {
$section = $id;
else
} else {
$section = new WP_Customize_Section( $this, $id, $args );
}
$this->sections[ $section->id ] = $section;
}
@ -825,11 +824,11 @@ final class WP_Customize_Manager {
* constructor.
*/
public function add_control( $id, $args = array() ) {
if ( is_a( $id, 'WP_Customize_Control' ) )
if ( $id instanceof WP_Customize_Control ) {
$control = $id;
else
} else {
$control = new WP_Customize_Control( $this, $id, $args );
}
$this->controls[ $control->id ] = $control;
}

View File

@ -214,8 +214,6 @@ class WP_Error {
* @param mixed $thing Check if unknown variable is a WP_Error object.
* @return bool True, if WP_Error. False, if not WP_Error.
*/
function is_wp_error($thing) {
if ( is_object($thing) && is_a($thing, 'WP_Error') )
return true;
return false;
function is_wp_error( $thing ) {
return ( $thing instanceof WP_Error );
}

View File

@ -274,7 +274,7 @@ final class WP_Theme implements ArrayAccess {
// Set the parent, if we're a child theme.
if ( $this->template != $this->stylesheet ) {
// If we are a parent, then there is a problem. Only two generations allowed! Cancel things out.
if ( is_a( $_child, 'WP_Theme' ) && $_child->template == $this->stylesheet ) {
if ( $_child instanceof WP_Theme && $_child->template == $this->stylesheet ) {
$_child->parent = null;
$_child->errors = new WP_Error( 'theme_parent_invalid', sprintf( __( 'The "%s" theme is not a valid parent theme.' ), $_child->template ) );
$_child->cache_add( 'theme', array( 'headers' => $_child->headers, 'errors' => $_child->errors, 'stylesheet' => $_child->stylesheet, 'template' => $_child->template ) );

View File

@ -1117,13 +1117,13 @@ class wp_xmlrpc_server extends IXR_Server {
return $this->error;
// convert the date field back to IXR form
if ( isset( $content_struct['post_date'] ) && ! is_a( $content_struct['post_date'], 'IXR_Date' ) ) {
if ( isset( $content_struct['post_date'] ) && ! ( $content_struct['post_date'] instanceof IXR_Date ) ) {
$content_struct['post_date'] = $this->_convert_date( $content_struct['post_date'] );
}
// ignore the existing GMT date if it is empty or a non-GMT date was supplied in $content_struct,
// since _insert_post will ignore the non-GMT date if the GMT date is set
if ( isset( $content_struct['post_date_gmt'] ) && ! is_a( $content_struct['post_date_gmt'], 'IXR_Date' ) ) {
if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) {
if ( $content_struct['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) {
unset( $content_struct['post_date_gmt'] );
} else {

View File

@ -65,7 +65,7 @@ if ( !function_exists('json_encode') ) {
function json_encode( $string ) {
global $wp_json;
if ( !is_a($wp_json, 'Services_JSON') ) {
if ( ! ( $wp_json instanceof Services_JSON ) ) {
require_once( ABSPATH . WPINC . '/class-json.php' );
$wp_json = new Services_JSON();
}
@ -78,7 +78,7 @@ if ( !function_exists('json_decode') ) {
function json_decode( $string, $assoc_array = false ) {
global $wp_json;
if ( !is_a($wp_json, 'Services_JSON') ) {
if ( ! ($wp_json instanceof Services_JSON ) ) {
require_once( ABSPATH . WPINC . '/class-json.php' );
$wp_json = new Services_JSON();
}

View File

@ -2684,7 +2684,7 @@ function sanitize_user_object($user, $context = 'display') {
if ( is_object($user) ) {
if ( !isset($user->ID) )
$user->ID = 0;
if ( !is_a( $user, 'WP_User' ) ) {
if ( ! ( $user instanceof WP_User ) ) {
$vars = get_object_vars($user);
foreach ( array_keys($vars) as $field ) {
if ( is_string($user->$field) || is_numeric($user->$field) )

View File

@ -35,7 +35,7 @@ function wp_print_scripts( $handles = false ) {
$handles = false;
global $wp_scripts;
if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
if ( ! did_action( 'init' ) )
_doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
@ -72,7 +72,7 @@ function wp_print_scripts( $handles = false ) {
*/
function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false ) {
global $wp_scripts;
if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
if ( ! did_action( 'init' ) )
_doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
@ -115,7 +115,7 @@ function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_f
*/
function wp_localize_script( $handle, $object_name, $l10n ) {
global $wp_scripts;
if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
if ( ! did_action( 'init' ) )
_doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
@ -141,7 +141,7 @@ function wp_localize_script( $handle, $object_name, $l10n ) {
*/
function wp_deregister_script( $handle ) {
global $wp_scripts;
if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
if ( ! did_action( 'init' ) )
_doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
@ -197,7 +197,7 @@ function wp_deregister_script( $handle ) {
*/
function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false, $in_footer = false ) {
global $wp_scripts;
if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
if ( ! did_action( 'init' ) )
_doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
@ -229,7 +229,7 @@ function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false
*/
function wp_dequeue_script( $handle ) {
global $wp_scripts;
if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
if ( ! did_action( 'init' ) )
_doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
@ -254,7 +254,7 @@ function wp_dequeue_script( $handle ) {
*/
function wp_script_is( $handle, $list = 'enqueued' ) {
global $wp_scripts;
if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
if ( ! did_action( 'init' ) )
_doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );

View File

@ -34,7 +34,7 @@ function wp_print_styles( $handles = false ) {
do_action( 'wp_print_styles' );
global $wp_styles;
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
if ( ! ( $wp_styles instanceof WP_Styles ) ) {
if ( ! did_action( 'init' ) )
_doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
@ -67,7 +67,7 @@ function wp_print_styles( $handles = false ) {
*/
function wp_add_inline_style( $handle, $data ) {
global $wp_styles;
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
if ( ! ( $wp_styles instanceof WP_Styles ) ) {
if ( ! did_action( 'init' ) )
_doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
@ -102,7 +102,7 @@ function wp_add_inline_style( $handle, $data ) {
*/
function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = 'all' ) {
global $wp_styles;
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
if ( ! ( $wp_styles instanceof WP_Styles ) ) {
if ( ! did_action( 'init' ) )
_doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
@ -124,7 +124,7 @@ function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media
*/
function wp_deregister_style( $handle ) {
global $wp_styles;
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
if ( ! ( $wp_styles instanceof WP_Styles ) ) {
if ( ! did_action( 'init' ) )
_doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
@ -157,7 +157,7 @@ function wp_deregister_style( $handle ) {
*/
function wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false, $media = 'all' ) {
global $wp_styles;
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
if ( ! ( $wp_styles instanceof WP_Styles ) ) {
if ( ! did_action( 'init' ) )
_doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
@ -183,7 +183,7 @@ function wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false,
*/
function wp_dequeue_style( $handle ) {
global $wp_styles;
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
if ( ! ( $wp_styles instanceof WP_Styles ) ) {
if ( ! did_action( 'init' ) )
_doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
@ -207,7 +207,7 @@ function wp_dequeue_style( $handle ) {
*/
function wp_style_is( $handle, $list = 'enqueued' ) {
global $wp_styles;
if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
if ( ! ( $wp_styles instanceof WP_Styles ) ) {
if ( ! did_action( 'init' ) )
_doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );

View File

@ -2849,8 +2849,9 @@ function wp_admin_css_uri( $file = 'wp-admin' ) {
*/
function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
global $wp_styles;
if ( !is_a($wp_styles, 'WP_Styles') )
if ( ! ( $wp_styles instanceof WP_Styles ) ) {
$wp_styles = new WP_Styles();
}
// For backward compatibility
$handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;

View File

@ -2005,11 +2005,12 @@ function fix_phpmailer_messageid( $phpmailer ) {
* @return bool
*/
function is_user_spammy( $user = null ) {
if ( ! is_a( $user, 'WP_User' ) ) {
if ( $user )
if ( ! ( $user instanceof WP_User ) ) {
if ( $user ) {
$user = get_user_by( 'login', $user );
else
} else {
$user = wp_get_current_user();
}
}
return $user && isset( $user->spam ) && 1 == $user->spam;

View File

@ -260,7 +260,7 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
global $phpmailer;
// (Re)create it, if it's gone missing
if ( !is_object( $phpmailer ) || !is_a( $phpmailer, 'PHPMailer' ) ) {
if ( ! ( $phpmailer instanceof PHPMailer ) ) {
require_once ABSPATH . WPINC . '/class-phpmailer.php';
require_once ABSPATH . WPINC . '/class-smtp.php';
$phpmailer = new PHPMailer( true );

View File

@ -422,7 +422,7 @@ function get_post( $post = null, $output = OBJECT, $filter = 'raw' ) {
if ( empty( $post ) && isset( $GLOBALS['post'] ) )
$post = $GLOBALS['post'];
if ( is_a( $post, 'WP_Post' ) ) {
if ( $post instanceof WP_Post ) {
$_post = $post;
} elseif ( is_object( $post ) ) {
if ( empty( $post->filter ) ) {

View File

@ -778,8 +778,9 @@ function print_head_scripts() {
do_action( 'wp_print_scripts' );
}
if ( !is_a($wp_scripts, 'WP_Scripts') )
if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
$wp_scripts = new WP_Scripts();
}
script_concat_settings();
$wp_scripts->do_concat = $concatenate_scripts;
@ -808,9 +809,9 @@ function print_head_scripts() {
function print_footer_scripts() {
global $wp_scripts, $concatenate_scripts;
if ( !is_a($wp_scripts, 'WP_Scripts') )
if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
return array(); // No need to run if not instantiated.
}
script_concat_settings();
$wp_scripts->do_concat = $concatenate_scripts;
$wp_scripts->do_footer_items();
@ -892,9 +893,9 @@ function wp_print_head_scripts() {
global $wp_scripts;
if ( !is_a($wp_scripts, 'WP_Scripts') )
if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
return array(); // no need to run if nothing is queued
}
return print_head_scripts();
}
@ -947,8 +948,9 @@ function wp_enqueue_scripts() {
function print_admin_styles() {
global $wp_styles, $concatenate_scripts;
if ( !is_a($wp_styles, 'WP_Styles') )
if ( ! ( $wp_styles instanceof WP_Styles ) ) {
$wp_styles = new WP_Styles();
}
script_concat_settings();
$wp_styles->do_concat = $concatenate_scripts;
@ -977,8 +979,9 @@ function print_admin_styles() {
function print_late_styles() {
global $wp_styles, $concatenate_scripts;
if ( !is_a($wp_styles, 'WP_Styles') )
if ( ! ( $wp_styles instanceof WP_Styles ) ) {
return;
}
$wp_styles->do_concat = $concatenate_scripts;
$wp_styles->do_footer_items();

View File

@ -135,7 +135,7 @@ function get_author_template() {
$templates = array();
if ( is_a( $author, 'WP_User' ) ) {
if ( $author instanceof WP_User ) {
$templates[] = "author-{$author->user_nicename}.php";
$templates[] = "author-{$author->ID}.php";
}

View File

@ -2027,5 +2027,5 @@ function wp_customize_support_script() {
function is_customize_preview() {
global $wp_customize;
return is_a( $wp_customize, 'WP_Customize_Manager' ) && $wp_customize->is_preview();
return ( $wp_customize instanceof WP_Customize_Manager ) && $wp_customize->is_preview();
}

View File

@ -112,7 +112,7 @@ function wp_signon( $credentials = array(), $secure_cookie = '' ) {
* @return WP_User|WP_Error WP_User on success, WP_Error on failure.
*/
function wp_authenticate_username_password($user, $username, $password) {
if ( is_a( $user, 'WP_User' ) ) {
if ( $user instanceof WP_User ) {
return $user;
}
@ -167,7 +167,7 @@ function wp_authenticate_username_password($user, $username, $password) {
* @return WP_User|WP_Error WP_User on success, WP_Error on failure.
*/
function wp_authenticate_cookie($user, $username, $password) {
if ( is_a( $user, 'WP_User' ) ) {
if ( $user instanceof WP_User ) {
return $user;
}
@ -202,7 +202,7 @@ function wp_authenticate_cookie($user, $username, $password) {
* @return WP_User|WP_Error WP_User on success, WP_Error if the user is considered a spammer.
*/
function wp_authenticate_spam_check( $user ) {
if ( $user && is_a( $user, 'WP_User' ) && is_multisite() ) {
if ( $user instanceof WP_User && is_multisite() ) {
/**
* Filter whether the user has been marked as a spammer.
*
@ -1710,9 +1710,9 @@ function validate_username( $username ) {
function wp_insert_user( $userdata ) {
global $wpdb;
if ( is_a( $userdata, 'stdClass' ) ) {
if ( $userdata instanceof stdClass ) {
$userdata = get_object_vars( $userdata );
} elseif ( is_a( $userdata, 'WP_User' ) ) {
} elseif ( $userdata instanceof WP_User ) {
$userdata = $userdata->to_array();
}
// Are we updating or creating?
@ -1969,10 +1969,11 @@ function wp_insert_user( $userdata ) {
* @return int|WP_Error The updated user's ID or a WP_Error object if the user could not be updated.
*/
function wp_update_user($userdata) {
if ( is_a( $userdata, 'stdClass' ) )
if ( $userdata instanceof stdClass ) {
$userdata = get_object_vars( $userdata );
elseif ( is_a( $userdata, 'WP_User' ) )
} elseif ( $userdata instanceof WP_User ) {
$userdata = $userdata->to_array();
}
$ID = (int) $userdata['ID'];

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.2-alpha-31187';
$wp_version = '4.2-alpha-31188';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -1552,8 +1552,9 @@ function the_widget( $widget, $instance = array(), $args = array() ) {
global $wp_widget_factory;
$widget_obj = $wp_widget_factory->widgets[$widget];
if ( !is_a($widget_obj, 'WP_Widget') )
if ( ! ( $widget_obj instanceof WP_Widget ) ) {
return;
}
$before_widget = sprintf('<div class="widget %s">', $widget_obj->widget_options['classname'] );
$default_args = array( 'before_widget' => $before_widget, 'after_widget' => "</div>", 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>' );