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-admin/includes/export.php

    r48185 r49108  
    373373        foreach ( $authors as $author ) {
    374374            echo "\t<wp:author>";
    375             echo '<wp:author_id>' . intval( $author->ID ) . '</wp:author_id>';
     375            echo '<wp:author_id>' . (int) $author->ID . '</wp:author_id>';
    376376            echo '<wp:author_login>' . wxr_cdata( $author->user_login ) . '</wp:author_login>';
    377377            echo '<wp:author_email>' . wxr_cdata( $author->user_email ) . '</wp:author_email>';
     
    396396        foreach ( $nav_menus as $menu ) {
    397397            echo "\t<wp:term>";
    398             echo '<wp:term_id>' . intval( $menu->term_id ) . '</wp:term_id>';
     398            echo '<wp:term_id>' . (int) $menu->term_id . '</wp:term_id>';
    399399            echo '<wp:term_taxonomy>nav_menu</wp:term_taxonomy>';
    400400            echo '<wp:term_slug>' . wxr_cdata( $menu->slug ) . '</wp:term_slug>';
     
    479479    <?php foreach ( $cats as $c ) : ?>
    480480    <wp:category>
    481         <wp:term_id><?php echo intval( $c->term_id ); ?></wp:term_id>
     481        <wp:term_id><?php echo (int) $c->term_id; ?></wp:term_id>
    482482        <wp:category_nicename><?php echo wxr_cdata( $c->slug ); ?></wp:category_nicename>
    483483        <wp:category_parent><?php echo wxr_cdata( $c->parent ? $cats[ $c->parent ]->slug : '' ); ?></wp:category_parent>
     
    491491    <?php foreach ( $tags as $t ) : ?>
    492492    <wp:tag>
    493         <wp:term_id><?php echo intval( $t->term_id ); ?></wp:term_id>
     493        <wp:term_id><?php echo (int) $t->term_id; ?></wp:term_id>
    494494        <wp:tag_slug><?php echo wxr_cdata( $t->slug ); ?></wp:tag_slug>
    495495        <?php
     
    502502    <?php foreach ( $terms as $t ) : ?>
    503503    <wp:term>
    504         <wp:term_id><?php echo intval( $t->term_id ); ?></wp:term_id>
     504        <wp:term_id><?php echo (int) $t->term_id; ?></wp:term_id>
    505505        <wp:term_taxonomy><?php echo wxr_cdata( $t->taxonomy ); ?></wp:term_taxonomy>
    506506        <wp:term_slug><?php echo wxr_cdata( $t->slug ); ?></wp:term_slug>
     
    574574        <content:encoded><?php echo $content; ?></content:encoded>
    575575        <excerpt:encoded><?php echo $excerpt; ?></excerpt:encoded>
    576         <wp:post_id><?php echo intval( $post->ID ); ?></wp:post_id>
     576        <wp:post_id><?php echo (int) $post->ID; ?></wp:post_id>
    577577        <wp:post_date><?php echo wxr_cdata( $post->post_date ); ?></wp:post_date>
    578578        <wp:post_date_gmt><?php echo wxr_cdata( $post->post_date_gmt ); ?></wp:post_date_gmt>
     
    581581        <wp:post_name><?php echo wxr_cdata( $post->post_name ); ?></wp:post_name>
    582582        <wp:status><?php echo wxr_cdata( $post->post_status ); ?></wp:status>
    583         <wp:post_parent><?php echo intval( $post->post_parent ); ?></wp:post_parent>
    584         <wp:menu_order><?php echo intval( $post->menu_order ); ?></wp:menu_order>
     583        <wp:post_parent><?php echo (int) $post->post_parent; ?></wp:post_parent>
     584        <wp:menu_order><?php echo (int) $post->menu_order; ?></wp:menu_order>
    585585        <wp:post_type><?php echo wxr_cdata( $post->post_type ); ?></wp:post_type>
    586586        <wp:post_password><?php echo wxr_cdata( $post->post_password ); ?></wp:post_password>
    587         <wp:is_sticky><?php echo intval( $is_sticky ); ?></wp:is_sticky>
     587        <wp:is_sticky><?php echo (int) $is_sticky; ?></wp:is_sticky>
    588588                <?php   if ( 'attachment' === $post->post_type ) : ?>
    589589        <wp:attachment_url><?php echo wxr_cdata( wp_get_attachment_url( $post->ID ) ); ?></wp:attachment_url>
     
    621621                    ?>
    622622        <wp:comment>
    623             <wp:comment_id><?php echo intval( $c->comment_ID ); ?></wp:comment_id>
     623            <wp:comment_id><?php echo (int) $c->comment_ID; ?></wp:comment_id>
    624624            <wp:comment_author><?php echo wxr_cdata( $c->comment_author ); ?></wp:comment_author>
    625625            <wp:comment_author_email><?php echo wxr_cdata( $c->comment_author_email ); ?></wp:comment_author_email>
     
    631631            <wp:comment_approved><?php echo wxr_cdata( $c->comment_approved ); ?></wp:comment_approved>
    632632            <wp:comment_type><?php echo wxr_cdata( $c->comment_type ); ?></wp:comment_type>
    633             <wp:comment_parent><?php echo intval( $c->comment_parent ); ?></wp:comment_parent>
    634             <wp:comment_user_id><?php echo intval( $c->user_id ); ?></wp:comment_user_id>
     633            <wp:comment_parent><?php echo (int) $c->comment_parent; ?></wp:comment_parent>
     634            <wp:comment_user_id><?php echo (int) $c->user_id; ?></wp:comment_user_id>
    635635                    <?php
    636636                    $c_meta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->commentmeta WHERE comment_id = %d", $c->comment_ID ) );
Note: See TracChangeset for help on using the changeset viewer.