Make WordPress Core


Ignore:
Timestamp:
01/16/2015 01:05:52 AM (9 years ago)
Author:
wonderboymusic
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/script-loader.php

    r31170 r31188  
    779779    }
    780780
    781     if ( !is_a($wp_scripts, 'WP_Scripts') )
     781    if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
    782782        $wp_scripts = new WP_Scripts();
     783    }
    783784
    784785    script_concat_settings();
     
    809810    global $wp_scripts, $concatenate_scripts;
    810811
    811     if ( !is_a($wp_scripts, 'WP_Scripts') )
     812    if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
    812813        return array(); // No need to run if not instantiated.
    813 
     814    }
    814815    script_concat_settings();
    815816    $wp_scripts->do_concat = $concatenate_scripts;
     
    893894    global $wp_scripts;
    894895
    895     if ( !is_a($wp_scripts, 'WP_Scripts') )
     896    if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
    896897        return array(); // no need to run if nothing is queued
    897 
     898    }
    898899    return print_head_scripts();
    899900}
     
    948949    global $wp_styles, $concatenate_scripts;
    949950
    950     if ( !is_a($wp_styles, 'WP_Styles') )
     951    if ( ! ( $wp_styles instanceof WP_Styles ) ) {
    951952        $wp_styles = new WP_Styles();
     953    }
    952954
    953955    script_concat_settings();
     
    978980    global $wp_styles, $concatenate_scripts;
    979981
    980     if ( !is_a($wp_styles, 'WP_Styles') )
     982    if ( ! ( $wp_styles instanceof WP_Styles ) ) {
    981983        return;
     984    }
    982985
    983986    $wp_styles->do_concat = $concatenate_scripts;
Note: See TracChangeset for help on using the changeset viewer.