Make WordPress Core


Ignore:
Timestamp:
10/08/2020 09:13:57 PM (4 years ago)
Author:
SergeyBiryukov
Message:

General: Replace older-style PHP type conversion functions with type casts.

This improves performance, readability, and consistency throughout core.

  • intval()(int)
  • strval()(string)
  • floatval()(float)

Props ayeshrajans.
Fixes #42918.

File:
1 edited

Legend:

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

    r49086 r49108  
    41364136
    41374137        if ( $thumbnail_support ) {
    4138             $thumbnail_id = intval( $postarr['_thumbnail_id'] );
     4138            $thumbnail_id = (int) $postarr['_thumbnail_id'];
    41394139            if ( -1 === $thumbnail_id ) {
    41404140                delete_post_thumbnail( $post_ID );
     
    45944594        $conflicts_with_date_archive = false;
    45954595        if ( 'post' === $post_type && ( ! $post || $post->post_name !== $slug ) && preg_match( '/^[0-9]+$/', $slug ) ) {
    4596             $slug_num = intval( $slug );
     4596            $slug_num = (int) $slug;
    45974597
    45984598            if ( $slug_num ) {
     
    52675267    $children = array();
    52685268    foreach ( (array) $pages as $page ) {
    5269         $children[ intval( $page->post_parent ) ][] = $page;
     5269        $children[ (int) $page->post_parent ][] = $page;
    52705270    }
    52715271
     
    53115311    $children = array();
    53125312    foreach ( (array) $pages as $p ) {
    5313         $parent_id                = intval( $p->post_parent );
     5313        $parent_id                = (int) $p->post_parent;
    53145314        $children[ $parent_id ][] = $p;
    53155315    }
     
    55205520            foreach ( $post_authors as $post_author ) {
    55215521                // Do we have an author id or an author login?
    5522                 if ( 0 == intval( $post_author ) ) {
     5522                if ( 0 == (int) $post_author ) {
    55235523                    $post_author = get_user_by( 'login', $post_author );
    55245524                    if ( empty( $post_author ) ) {
Note: See TracChangeset for help on using the changeset viewer.