Make WordPress Core


Ignore:
Timestamp:
01/16/2015 01:05:52 AM (10 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/functions.wp-scripts.php

    r31030 r31188  
    3636
    3737    global $wp_scripts;
    38     if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
     38    if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
    3939        if ( ! did_action( 'init' ) )
    4040            _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
     
    7373function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false ) {
    7474    global $wp_scripts;
    75     if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
     75    if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
    7676        if ( ! did_action( 'init' ) )
    7777            _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
     
    116116function wp_localize_script( $handle, $object_name, $l10n ) {
    117117    global $wp_scripts;
    118     if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
     118    if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
    119119        if ( ! did_action( 'init' ) )
    120120            _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
     
    142142function wp_deregister_script( $handle ) {
    143143    global $wp_scripts;
    144     if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
     144    if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
    145145        if ( ! did_action( 'init' ) )
    146146            _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
     
    198198function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false, $in_footer = false ) {
    199199    global $wp_scripts;
    200     if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
     200    if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
    201201        if ( ! did_action( 'init' ) )
    202202            _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
     
    230230function wp_dequeue_script( $handle ) {
    231231    global $wp_scripts;
    232     if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
     232    if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
    233233        if ( ! did_action( 'init' ) )
    234234            _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
     
    255255function wp_script_is( $handle, $list = 'enqueued' ) {
    256256    global $wp_scripts;
    257     if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
     257    if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
    258258        if ( ! did_action( 'init' ) )
    259259            _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
Note: See TracChangeset for help on using the changeset viewer.