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.


git-svn-id: https://develop.svn.wordpress.org/trunk@31188 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2015-01-16 01:05:52 +00:00
parent 102fb4ac5c
commit 5acc6bdb58
24 changed files with 76 additions and 68 deletions

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();