WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/16/2015 01:05:52 AM (5 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-styles.php

    r30674 r31188  
    3535
    3636    global $wp_styles;
    37     if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
     37    if ( ! ( $wp_styles instanceof WP_Styles ) ) {
    3838        if ( ! did_action( 'init' ) )
    3939            _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
     
    6868function wp_add_inline_style( $handle, $data ) {
    6969    global $wp_styles;
    70     if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
     70    if ( ! ( $wp_styles instanceof WP_Styles ) ) {
    7171        if ( ! did_action( 'init' ) )
    7272            _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
     
    103103function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = 'all' ) {
    104104    global $wp_styles;
    105     if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
     105    if ( ! ( $wp_styles instanceof WP_Styles ) ) {
    106106        if ( ! did_action( 'init' ) )
    107107            _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
     
    125125function wp_deregister_style( $handle ) {
    126126    global $wp_styles;
    127     if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
     127    if ( ! ( $wp_styles instanceof WP_Styles ) ) {
    128128        if ( ! did_action( 'init' ) )
    129129            _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
     
    158158function wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false, $media = 'all' ) {
    159159    global $wp_styles;
    160     if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
     160    if ( ! ( $wp_styles instanceof WP_Styles ) ) {
    161161        if ( ! did_action( 'init' ) )
    162162            _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
     
    184184function wp_dequeue_style( $handle ) {
    185185    global $wp_styles;
    186     if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
     186    if ( ! ( $wp_styles instanceof WP_Styles ) ) {
    187187        if ( ! did_action( 'init' ) )
    188188            _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
     
    208208function wp_style_is( $handle, $list = 'enqueued' ) {
    209209    global $wp_styles;
    210     if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
     210    if ( ! ( $wp_styles instanceof WP_Styles ) ) {
    211211        if ( ! did_action( 'init' ) )
    212212            _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.