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/customize/class-wp-customize-nav-menu-setting.php

    r47557 r49108  
    142142        }
    143143
    144         $this->term_id = intval( $matches['id'] );
     144        $this->term_id = (int) $matches['id'];
    145145
    146146        parent::__construct( $manager, $id, $args );
     
    434434        $value['name']        = trim( esc_html( $value['name'] ) ); // This sanitization code is used in wp-admin/nav-menus.php.
    435435        $value['description'] = sanitize_text_field( $value['description'] );
    436         $value['parent']      = max( 0, intval( $value['parent'] ) );
     436        $value['parent']      = max( 0, (int) $value['parent'] );
    437437        $value['auto_add']    = ! empty( $value['auto_add'] );
    438438
     
    557557
    558558                $post_value = $setting->post_value( null );
    559                 if ( ! is_null( $post_value ) && intval( $post_value ) === $this->previous_term_id ) {
     559                if ( ! is_null( $post_value ) && (int) $post_value === $this->previous_term_id ) {
    560560                    $this->manager->set_post_value( $setting->id, $this->term_id );
    561561                    $setting->save();
     
    571571
    572572                $widget_instance = $nav_menu_widget_setting->post_value(); // Note that this calls WP_Customize_Widgets::sanitize_widget_instance().
    573                 if ( empty( $widget_instance['nav_menu'] ) || intval( $widget_instance['nav_menu'] ) !== $this->previous_term_id ) {
     573                if ( empty( $widget_instance['nav_menu'] ) || (int) $widget_instance['nav_menu'] !== $this->previous_term_id ) {
    574574                    continue;
    575575                }
Note: See TracChangeset for help on using the changeset viewer.