Make WordPress Core


Ignore:
Timestamp:
01/16/2015 01:05:52 AM (12 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/class-wp-customize-manager.php

    r31085 r31188  
    696696         */
    697697        public function add_setting( $id, $args = array() ) {
    698                 if ( is_a( $id, 'WP_Customize_Setting' ) )
     698                if ( $id instanceof WP_Customize_Setting ) {
    699699                        $setting = $id;
    700                 else
     700                } else {
    701701                        $setting = new WP_Customize_Setting( $this, $id, $args );
    702 
     702                }
    703703                $this->settings[ $setting->id ] = $setting;
    704704        }
    … …  
    738738         */
    739739        public function add_panel( $id, $args = array() ) {
    740                 if ( is_a( $id, 'WP_Customize_Panel' ) ) {
     740                if ( $id instanceof WP_Customize_Panel ) {
    741741                        $panel = $id;
    742                 }
    743                 else {
     742                } else {
    744743                        $panel = new WP_Customize_Panel( $this, $id, $args );
    745744                }
    … …  
    784783         */
    785784        public function add_section( $id, $args = array() ) {
    786                 if ( is_a( $id, 'WP_Customize_Section' ) )
     785                if ( $id instanceof WP_Customize_Section ) {
    787786                        $section = $id;
    788                 else
     787                } else {
    789788                        $section = new WP_Customize_Section( $this, $id, $args );
    790 
     789                }
    791790                $this->sections[ $section->id ] = $section;
    792791        }
    … …  
    826825         */
    827826        public function add_control( $id, $args = array() ) {
    828                 if ( is_a( $id, 'WP_Customize_Control' ) )
     827                if ( $id instanceof WP_Customize_Control ) {
    829828                        $control = $id;
    830                 else
     829                } else {
    831830                        $control = new WP_Customize_Control( $this, $id, $args );
    832 
     831                }
    833832                $this->controls[ $control->id ] = $control;
    834833        }
Note: See TracChangeset for help on using the changeset viewer.