Make WordPress Core

Changeset 49194


Ignore:
Timestamp:
10/18/2020 05:31:37 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Use instanceof instead of a comparison with get_class().

Includes adjusting external libraries which are no longer maintained externally.

Props jrf.
See #50767.

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-pclzip.php

    r47123 r49194  
    11721172
    11731173    // ----- Look if the $p_archive is a PclZip object
    1174     if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip'))
     1174    if (is_object($p_archive) && $p_archive instanceof pclzip)
    11751175    {
    11761176
     
    12361236
    12371237    // ----- Look if the $p_archive_to_add is a PclZip object
    1238     if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip'))
     1238    if (is_object($p_archive_to_add) && $p_archive_to_add instanceof pclzip)
    12391239    {
    12401240
  • trunk/src/wp-includes/Text/Diff.php

    r49185 r49194  
    277277        $prevtype = null;
    278278        foreach ($this->_edits as $edit) {
    279             if ($prevtype == get_class($edit)) {
     279            if ($edit instanceof $prevtype) {
    280280                trigger_error("Edit sequence is non-optimal", E_USER_ERROR);
    281281            }
  • trunk/src/wp-includes/class-json.php

    r49108 r49194  
    919919        if (class_exists('pear')) {
    920920            return PEAR::isError($data, $code);
    921         } elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
     921        } elseif (is_object($data) && ($data instanceof services_json_error ||
    922922                                 is_subclass_of($data, 'services_json_error'))) {
    923923            return true;
  • trunk/src/wp-includes/rest-api.php

    r49154 r49194  
    23912391
    23922392    // The only controller that works is the Terms controller.
    2393     if ( 'WP_REST_Terms_Controller' === get_class( $controller ) ) {
     2393    if ( $controller instanceof WP_REST_Terms_Controller ) {
    23942394        $namespace = 'wp/v2';
    23952395        $rest_base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
Note: See TracChangeset for help on using the changeset viewer.