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/link-template.php

    r49067 r49108  
    516516    if ( ! empty( $monthlink ) ) {
    517517        $monthlink = str_replace( '%year%', $year, $monthlink );
    518         $monthlink = str_replace( '%monthnum%', zeroise( intval( $month ), 2 ), $monthlink );
     518        $monthlink = str_replace( '%monthnum%', zeroise( (int) $month, 2 ), $monthlink );
    519519        $monthlink = home_url( user_trailingslashit( $monthlink, 'month' ) );
    520520    } else {
     
    561561    if ( ! empty( $daylink ) ) {
    562562        $daylink = str_replace( '%year%', $year, $daylink );
    563         $daylink = str_replace( '%monthnum%', zeroise( intval( $month ), 2 ), $daylink );
    564         $daylink = str_replace( '%day%', zeroise( intval( $day ), 2 ), $daylink );
     563        $daylink = str_replace( '%monthnum%', zeroise( (int) $month, 2 ), $daylink );
     564        $daylink = str_replace( '%day%', zeroise( (int) $day, 2 ), $daylink );
    565565        $daylink = home_url( user_trailingslashit( $daylink, 'day' ) );
    566566    } else {
     
    23212321            $paged = 1;
    23222322        }
    2323         $nextpage = intval( $paged ) + 1;
     2323        $nextpage = (int) $paged + 1;
    23242324        if ( ! $max_page || $max_page >= $nextpage ) {
    23252325            return get_pagenum_link( $nextpage );
     
    23702370    }
    23712371
    2372     $nextpage = intval( $paged ) + 1;
     2372    $nextpage = (int) $paged + 1;
    23732373
    23742374    if ( null === $label ) {
     
    24192419
    24202420    if ( ! is_single() ) {
    2421         $nextpage = intval( $paged ) - 1;
     2421        $nextpage = (int) $paged - 1;
    24222422        if ( $nextpage < 1 ) {
    24232423            $nextpage = 1;
     
    28922892    }
    28932893
    2894     $nextpage = intval( $page ) + 1;
     2894    $nextpage = (int) $page + 1;
    28952895
    28962896    if ( empty( $max_page ) ) {
     
    29472947    $page = get_query_var( 'cpage' );
    29482948
    2949     if ( intval( $page ) <= 1 ) {
     2949    if ( (int) $page <= 1 ) {
    29502950        return;
    29512951    }
    29522952
    2953     $prevpage = intval( $page ) - 1;
     2953    $prevpage = (int) $page - 1;
    29542954
    29552955    if ( empty( $label ) ) {
Note: See TracChangeset for help on using the changeset viewer.