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.
Built from https://develop.svn.wordpress.org/trunk@49108


git-svn-id: http://core.svn.wordpress.org/trunk@48870 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-10-08 21:15:13 +00:00
parent f25804699f
commit 897f004a9c
79 changed files with 273 additions and 274 deletions

View File

@ -170,7 +170,7 @@ if ( $current_screen->taxonomy ) {
$admin_body_class .= ' taxonomy-' . $current_screen->taxonomy; $admin_body_class .= ' taxonomy-' . $current_screen->taxonomy;
} }
$admin_body_class .= ' branch-' . str_replace( array( '.', ',' ), '-', floatval( get_bloginfo( 'version' ) ) ); $admin_body_class .= ' branch-' . str_replace( array( '.', ',' ), '-', (float) get_bloginfo( 'version' ) );
$admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '/^([.0-9]+).*/', '$1', get_bloginfo( 'version' ) ) ); $admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '/^([.0-9]+).*/', '$1', get_bloginfo( 'version' ) ) );
$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) ); $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );

View File

@ -39,8 +39,8 @@ if ( ! current_user_can( 'upload_files' ) ) {
} }
// Just fetch the detail form for that attachment. // Just fetch the detail form for that attachment.
if ( isset( $_REQUEST['attachment_id'] ) && intval( $_REQUEST['attachment_id'] ) && $_REQUEST['fetch'] ) { if ( isset( $_REQUEST['attachment_id'] ) && (int) $_REQUEST['attachment_id'] && $_REQUEST['fetch'] ) {
$id = intval( $_REQUEST['attachment_id'] ); $id = (int) $_REQUEST['attachment_id'];
$post = get_post( $id ); $post = get_post( $id );
if ( 'attachment' !== $post->post_type ) { if ( 'attachment' !== $post->post_type ) {
wp_die( __( 'Invalid post type.' ) ); wp_die( __( 'Invalid post type.' ) );

View File

@ -329,7 +329,7 @@ if ( isset( $_REQUEST['approved'] ) || isset( $_REQUEST['deleted'] ) || isset( $
<?php $wp_list_table->search_box( __( 'Search Comments' ), 'comment' ); ?> <?php $wp_list_table->search_box( __( 'Search Comments' ), 'comment' ); ?>
<?php if ( $post_id ) : ?> <?php if ( $post_id ) : ?>
<input type="hidden" name="p" value="<?php echo esc_attr( intval( $post_id ) ); ?>" /> <input type="hidden" name="p" value="<?php echo esc_attr( (int) $post_id ); ?>" />
<?php endif; ?> <?php endif; ?>
<input type="hidden" name="comment_status" value="<?php echo esc_attr( $comment_status ); ?>" /> <input type="hidden" name="comment_status" value="<?php echo esc_attr( $comment_status ); ?>" />
<input type="hidden" name="pagegen_timestamp" value="<?php echo esc_attr( current_time( 'mysql', 1 ) ); ?>" /> <input type="hidden" name="pagegen_timestamp" value="<?php echo esc_attr( current_time( 'mysql', 1 ) ); ?>" />

View File

@ -227,7 +227,7 @@ function wp_ajax_wp_compression_test() {
* @since 3.1.0 * @since 3.1.0
*/ */
function wp_ajax_imgedit_preview() { function wp_ajax_imgedit_preview() {
$post_id = intval( $_GET['postid'] ); $post_id = (int) $_GET['postid'];
if ( empty( $post_id ) || ! current_user_can( 'edit_post', $post_id ) ) { if ( empty( $post_id ) || ! current_user_can( 'edit_post', $post_id ) ) {
wp_die( -1 ); wp_die( -1 );
} }
@ -1954,7 +1954,7 @@ function wp_ajax_menu_quick_search() {
*/ */
function wp_ajax_get_permalink() { function wp_ajax_get_permalink() {
check_ajax_referer( 'getpermalink', 'getpermalinknonce' ); check_ajax_referer( 'getpermalink', 'getpermalinknonce' );
$post_id = isset( $_POST['post_id'] ) ? intval( $_POST['post_id'] ) : 0; $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0;
wp_die( get_preview_post_link( $post_id ) ); wp_die( get_preview_post_link( $post_id ) );
} }
@ -1965,7 +1965,7 @@ function wp_ajax_get_permalink() {
*/ */
function wp_ajax_sample_permalink() { function wp_ajax_sample_permalink() {
check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' ); check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' );
$post_id = isset( $_POST['post_id'] ) ? intval( $_POST['post_id'] ) : 0; $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0;
$title = isset( $_POST['new_title'] ) ? $_POST['new_title'] : ''; $title = isset( $_POST['new_title'] ) ? $_POST['new_title'] : '';
$slug = isset( $_POST['new_slug'] ) ? $_POST['new_slug'] : null; $slug = isset( $_POST['new_slug'] ) ? $_POST['new_slug'] : null;
wp_die( get_sample_permalink_html( $post_id, $title, $slug ) ); wp_die( get_sample_permalink_html( $post_id, $title, $slug ) );
@ -2594,7 +2594,7 @@ function wp_ajax_upload_attachment() {
* @since 3.1.0 * @since 3.1.0
*/ */
function wp_ajax_image_editor() { function wp_ajax_image_editor() {
$attachment_id = intval( $_POST['postid'] ); $attachment_id = (int) $_POST['postid'];
if ( empty( $attachment_id ) || ! current_user_can( 'edit_post', $attachment_id ) ) { if ( empty( $attachment_id ) || ! current_user_can( 'edit_post', $attachment_id ) ) {
wp_die( -1 ); wp_die( -1 );
@ -2651,12 +2651,12 @@ function wp_ajax_image_editor() {
function wp_ajax_set_post_thumbnail() { function wp_ajax_set_post_thumbnail() {
$json = ! empty( $_REQUEST['json'] ); // New-style request. $json = ! empty( $_REQUEST['json'] ); // New-style request.
$post_ID = intval( $_POST['post_id'] ); $post_ID = (int) $_POST['post_id'];
if ( ! current_user_can( 'edit_post', $post_ID ) ) { if ( ! current_user_can( 'edit_post', $post_ID ) ) {
wp_die( -1 ); wp_die( -1 );
} }
$thumbnail_id = intval( $_POST['thumbnail_id'] ); $thumbnail_id = (int) $_POST['thumbnail_id'];
if ( $json ) { if ( $json ) {
check_ajax_referer( "update-post_$post_ID" ); check_ajax_referer( "update-post_$post_ID" );
@ -2687,7 +2687,7 @@ function wp_ajax_set_post_thumbnail() {
* @since 4.6.0 * @since 4.6.0
*/ */
function wp_ajax_get_post_thumbnail_html() { function wp_ajax_get_post_thumbnail_html() {
$post_ID = intval( $_POST['post_id'] ); $post_ID = (int) $_POST['post_id'];
check_ajax_referer( "update-post_$post_ID" ); check_ajax_referer( "update-post_$post_ID" );
@ -2695,7 +2695,7 @@ function wp_ajax_get_post_thumbnail_html() {
wp_die( -1 ); wp_die( -1 );
} }
$thumbnail_id = intval( $_POST['thumbnail_id'] ); $thumbnail_id = (int) $_POST['thumbnail_id'];
// For backward compatibility, -1 refers to no featured image. // For backward compatibility, -1 refers to no featured image.
if ( -1 === $thumbnail_id ) { if ( -1 === $thumbnail_id ) {
@ -3208,7 +3208,7 @@ function wp_ajax_send_attachment_to_editor() {
$attachment = wp_unslash( $_POST['attachment'] ); $attachment = wp_unslash( $_POST['attachment'] );
$id = intval( $attachment['id'] ); $id = (int) $attachment['id'];
$post = get_post( $id ); $post = get_post( $id );
if ( ! $post ) { if ( ! $post ) {
@ -3221,7 +3221,7 @@ function wp_ajax_send_attachment_to_editor() {
if ( current_user_can( 'edit_post', $id ) ) { if ( current_user_can( 'edit_post', $id ) ) {
// If this attachment is unattached, attach it. Primarily a back compat thing. // If this attachment is unattached, attach it. Primarily a back compat thing.
$insert_into_post_id = intval( $_POST['post_id'] ); $insert_into_post_id = (int) $_POST['post_id'];
if ( 0 == $post->post_parent && $insert_into_post_id ) { if ( 0 == $post->post_parent && $insert_into_post_id ) {
wp_update_post( wp_update_post(
@ -3622,7 +3622,7 @@ function wp_ajax_parse_embed() {
wp_send_json_error(); wp_send_json_error();
} }
$post_id = isset( $_POST['post_ID'] ) ? intval( $_POST['post_ID'] ) : 0; $post_id = isset( $_POST['post_ID'] ) ? (int) $_POST['post_ID'] : 0;
if ( $post_id > 0 ) { if ( $post_id > 0 ) {
$post = get_post( $post_id ); $post = get_post( $post_id );
@ -3674,9 +3674,9 @@ function wp_ajax_parse_embed() {
// Set $content_width so any embeds fit in the destination iframe. // Set $content_width so any embeds fit in the destination iframe.
if ( isset( $_POST['maxwidth'] ) && is_numeric( $_POST['maxwidth'] ) && $_POST['maxwidth'] > 0 ) { if ( isset( $_POST['maxwidth'] ) && is_numeric( $_POST['maxwidth'] ) && $_POST['maxwidth'] > 0 ) {
if ( ! isset( $content_width ) ) { if ( ! isset( $content_width ) ) {
$content_width = intval( $_POST['maxwidth'] ); $content_width = (int) $_POST['maxwidth'];
} else { } else {
$content_width = min( $content_width, intval( $_POST['maxwidth'] ) ); $content_width = min( $content_width, (int) $_POST['maxwidth'] );
} }
} }

View File

@ -74,7 +74,7 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
public function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) { public function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) {
global $_nav_menu_placeholder, $nav_menu_selected_id; global $_nav_menu_placeholder, $nav_menu_selected_id;
$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval( $_nav_menu_placeholder ) - 1 : -1; $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? (int) $_nav_menu_placeholder - 1 : -1;
$possible_object_id = isset( $item->post_type ) && 'nav_menu_item' === $item->post_type ? $item->object_id : $_nav_menu_placeholder; $possible_object_id = isset( $item->post_type ) && 'nav_menu_item' === $item->post_type ? $item->object_id : $_nav_menu_placeholder;
$possible_db_id = ( ! empty( $item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0; $possible_db_id = ( ! empty( $item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0;

View File

@ -37,7 +37,7 @@ class WP_Importer {
if ( ! empty( $results ) ) { if ( ! empty( $results ) ) {
foreach ( $results as $r ) { foreach ( $results as $r ) {
// Set permalinks into array. // Set permalinks into array.
$hashtable[ $r->meta_value ] = intval( $r->post_id ); $hashtable[ $r->meta_value ] = (int) $r->post_id;
} }
} }
} while ( count( $results ) == $limit ); } while ( count( $results ) == $limit );
@ -69,7 +69,7 @@ class WP_Importer {
$result = $wpdb->get_results( $sql ); $result = $wpdb->get_results( $sql );
if ( ! empty( $result ) ) { if ( ! empty( $result ) ) {
$count = intval( $result[0]->cnt ); $count = (int) $result[0]->cnt;
} }
// Unset to save memory. // Unset to save memory.
@ -106,11 +106,11 @@ class WP_Importer {
foreach ( $results as $r ) { foreach ( $results as $r ) {
// Explode comment_agent key. // Explode comment_agent key.
list ( $ca_bid, $source_comment_id ) = explode( '-', $r->comment_agent ); list ( $ca_bid, $source_comment_id ) = explode( '-', $r->comment_agent );
$source_comment_id = intval( $source_comment_id ); $source_comment_id = (int) $source_comment_id;
// Check if this comment came from this blog. // Check if this comment came from this blog.
if ( $bid == $ca_bid ) { if ( $bid == $ca_bid ) {
$hashtable[ $source_comment_id ] = intval( $r->comment_ID ); $hashtable[ $source_comment_id ] = (int) $r->comment_ID;
} }
} }
} }

View File

@ -103,8 +103,8 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
} }
$args = array( $args = array(
'number' => intval( $per_page ), 'number' => (int) $per_page,
'offset' => intval( ( $pagenum - 1 ) * $per_page ), 'offset' => (int) ( ( $pagenum - 1 ) * $per_page ),
'network_id' => get_current_network_id(), 'network_id' => get_current_network_id(),
); );
@ -620,7 +620,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
$site_status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : ''; $site_status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : '';
foreach ( $this->status_list as $status => $col ) { foreach ( $this->status_list as $status => $col ) {
if ( ( 1 === intval( $_site->{$status} ) ) && ( $site_status !== $status ) ) { if ( ( 1 === (int) $_site->{$status} ) && ( $site_status !== $status ) ) {
$site_states[ $col[0] ] = $col[1]; $site_states[ $col[0] ] = $col[1];
} }
} }

View File

@ -63,7 +63,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
$this->is_site_themes = ( 'site-themes-network' === $this->screen->id ) ? true : false; $this->is_site_themes = ( 'site-themes-network' === $this->screen->id ) ? true : false;
if ( $this->is_site_themes ) { if ( $this->is_site_themes ) {
$this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; $this->site_id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0;
} }
$this->show_autoupdates = wp_is_auto_update_enabled_for_type( 'theme' ) && $this->show_autoupdates = wp_is_auto_update_enabled_for_type( 'theme' ) &&

View File

@ -89,19 +89,17 @@ class WP_Posts_List_Table extends WP_List_Table {
'show_in_admin_all_list' => false, 'show_in_admin_all_list' => false,
) )
); );
$this->user_posts_count = intval( $this->user_posts_count = (int) $wpdb->get_var(
$wpdb->get_var( $wpdb->prepare(
$wpdb->prepare( "
"
SELECT COUNT( 1 ) SELECT COUNT( 1 )
FROM $wpdb->posts FROM $wpdb->posts
WHERE post_type = %s WHERE post_type = %s
AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' ) AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' )
AND post_author = %d AND post_author = %d
", ",
$post_type, $post_type,
get_current_user_id() get_current_user_id()
)
) )
); );

View File

@ -54,7 +54,7 @@ class WP_Users_List_Table extends WP_List_Table {
$this->is_site_users = 'site-users-network' === $this->screen->id; $this->is_site_users = 'site-users-network' === $this->screen->id;
if ( $this->is_site_users ) { if ( $this->is_site_users ) {
$this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; $this->site_id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0;
} }
} }

View File

@ -606,7 +606,7 @@ function wp_dashboard_recent_drafts( $drafts = false ) {
echo '<h2 class="hide-if-no-js">' . __( 'Your Recent Drafts' ) . "</h2>\n<ul>"; echo '<h2 class="hide-if-no-js">' . __( 'Your Recent Drafts' ) . "</h2>\n<ul>";
/* translators: Maximum number of words used in a preview of a draft on the dashboard. */ /* translators: Maximum number of words used in a preview of a draft on the dashboard. */
$draft_length = intval( _x( '10', 'draft_length' ) ); $draft_length = (int) _x( '10', 'draft_length' );
$drafts = array_slice( $drafts, 0, 3 ); $drafts = array_slice( $drafts, 0, 3 );
foreach ( $drafts as $draft ) { foreach ( $drafts as $draft ) {
@ -928,7 +928,7 @@ function wp_dashboard_recent_posts( $args ) {
'post_status' => $args['status'], 'post_status' => $args['status'],
'orderby' => 'date', 'orderby' => 'date',
'order' => $args['order'], 'order' => $args['order'],
'posts_per_page' => intval( $args['max'] ), 'posts_per_page' => (int) $args['max'],
'no_found_rows' => true, 'no_found_rows' => true,
'cache_results' => false, 'cache_results' => false,
'perm' => ( 'future' === $args['status'] ) ? 'editable' : 'readable', 'perm' => ( 'future' === $args['status'] ) ? 'editable' : 'readable',

View File

@ -372,7 +372,7 @@ function export_wp( $args = array() ) {
foreach ( $authors as $author ) { foreach ( $authors as $author ) {
echo "\t<wp:author>"; echo "\t<wp:author>";
echo '<wp:author_id>' . intval( $author->ID ) . '</wp:author_id>'; echo '<wp:author_id>' . (int) $author->ID . '</wp:author_id>';
echo '<wp:author_login>' . wxr_cdata( $author->user_login ) . '</wp:author_login>'; echo '<wp:author_login>' . wxr_cdata( $author->user_login ) . '</wp:author_login>';
echo '<wp:author_email>' . wxr_cdata( $author->user_email ) . '</wp:author_email>'; echo '<wp:author_email>' . wxr_cdata( $author->user_email ) . '</wp:author_email>';
echo '<wp:author_display_name>' . wxr_cdata( $author->display_name ) . '</wp:author_display_name>'; echo '<wp:author_display_name>' . wxr_cdata( $author->display_name ) . '</wp:author_display_name>';
@ -395,7 +395,7 @@ function export_wp( $args = array() ) {
foreach ( $nav_menus as $menu ) { foreach ( $nav_menus as $menu ) {
echo "\t<wp:term>"; echo "\t<wp:term>";
echo '<wp:term_id>' . intval( $menu->term_id ) . '</wp:term_id>'; echo '<wp:term_id>' . (int) $menu->term_id . '</wp:term_id>';
echo '<wp:term_taxonomy>nav_menu</wp:term_taxonomy>'; echo '<wp:term_taxonomy>nav_menu</wp:term_taxonomy>';
echo '<wp:term_slug>' . wxr_cdata( $menu->slug ) . '</wp:term_slug>'; echo '<wp:term_slug>' . wxr_cdata( $menu->slug ) . '</wp:term_slug>';
wxr_term_name( $menu ); wxr_term_name( $menu );
@ -478,7 +478,7 @@ function export_wp( $args = array() ) {
<?php foreach ( $cats as $c ) : ?> <?php foreach ( $cats as $c ) : ?>
<wp:category> <wp:category>
<wp:term_id><?php echo intval( $c->term_id ); ?></wp:term_id> <wp:term_id><?php echo (int) $c->term_id; ?></wp:term_id>
<wp:category_nicename><?php echo wxr_cdata( $c->slug ); ?></wp:category_nicename> <wp:category_nicename><?php echo wxr_cdata( $c->slug ); ?></wp:category_nicename>
<wp:category_parent><?php echo wxr_cdata( $c->parent ? $cats[ $c->parent ]->slug : '' ); ?></wp:category_parent> <wp:category_parent><?php echo wxr_cdata( $c->parent ? $cats[ $c->parent ]->slug : '' ); ?></wp:category_parent>
<?php <?php
@ -490,7 +490,7 @@ function export_wp( $args = array() ) {
<?php endforeach; ?> <?php endforeach; ?>
<?php foreach ( $tags as $t ) : ?> <?php foreach ( $tags as $t ) : ?>
<wp:tag> <wp:tag>
<wp:term_id><?php echo intval( $t->term_id ); ?></wp:term_id> <wp:term_id><?php echo (int) $t->term_id; ?></wp:term_id>
<wp:tag_slug><?php echo wxr_cdata( $t->slug ); ?></wp:tag_slug> <wp:tag_slug><?php echo wxr_cdata( $t->slug ); ?></wp:tag_slug>
<?php <?php
wxr_tag_name( $t ); wxr_tag_name( $t );
@ -501,7 +501,7 @@ function export_wp( $args = array() ) {
<?php endforeach; ?> <?php endforeach; ?>
<?php foreach ( $terms as $t ) : ?> <?php foreach ( $terms as $t ) : ?>
<wp:term> <wp:term>
<wp:term_id><?php echo intval( $t->term_id ); ?></wp:term_id> <wp:term_id><?php echo (int) $t->term_id; ?></wp:term_id>
<wp:term_taxonomy><?php echo wxr_cdata( $t->taxonomy ); ?></wp:term_taxonomy> <wp:term_taxonomy><?php echo wxr_cdata( $t->taxonomy ); ?></wp:term_taxonomy>
<wp:term_slug><?php echo wxr_cdata( $t->slug ); ?></wp:term_slug> <wp:term_slug><?php echo wxr_cdata( $t->slug ); ?></wp:term_slug>
<wp:term_parent><?php echo wxr_cdata( $t->parent ? $terms[ $t->parent ]->slug : '' ); ?></wp:term_parent> <wp:term_parent><?php echo wxr_cdata( $t->parent ? $terms[ $t->parent ]->slug : '' ); ?></wp:term_parent>
@ -573,18 +573,18 @@ function export_wp( $args = array() ) {
<description></description> <description></description>
<content:encoded><?php echo $content; ?></content:encoded> <content:encoded><?php echo $content; ?></content:encoded>
<excerpt:encoded><?php echo $excerpt; ?></excerpt:encoded> <excerpt:encoded><?php echo $excerpt; ?></excerpt:encoded>
<wp:post_id><?php echo intval( $post->ID ); ?></wp:post_id> <wp:post_id><?php echo (int) $post->ID; ?></wp:post_id>
<wp:post_date><?php echo wxr_cdata( $post->post_date ); ?></wp:post_date> <wp:post_date><?php echo wxr_cdata( $post->post_date ); ?></wp:post_date>
<wp:post_date_gmt><?php echo wxr_cdata( $post->post_date_gmt ); ?></wp:post_date_gmt> <wp:post_date_gmt><?php echo wxr_cdata( $post->post_date_gmt ); ?></wp:post_date_gmt>
<wp:comment_status><?php echo wxr_cdata( $post->comment_status ); ?></wp:comment_status> <wp:comment_status><?php echo wxr_cdata( $post->comment_status ); ?></wp:comment_status>
<wp:ping_status><?php echo wxr_cdata( $post->ping_status ); ?></wp:ping_status> <wp:ping_status><?php echo wxr_cdata( $post->ping_status ); ?></wp:ping_status>
<wp:post_name><?php echo wxr_cdata( $post->post_name ); ?></wp:post_name> <wp:post_name><?php echo wxr_cdata( $post->post_name ); ?></wp:post_name>
<wp:status><?php echo wxr_cdata( $post->post_status ); ?></wp:status> <wp:status><?php echo wxr_cdata( $post->post_status ); ?></wp:status>
<wp:post_parent><?php echo intval( $post->post_parent ); ?></wp:post_parent> <wp:post_parent><?php echo (int) $post->post_parent; ?></wp:post_parent>
<wp:menu_order><?php echo intval( $post->menu_order ); ?></wp:menu_order> <wp:menu_order><?php echo (int) $post->menu_order; ?></wp:menu_order>
<wp:post_type><?php echo wxr_cdata( $post->post_type ); ?></wp:post_type> <wp:post_type><?php echo wxr_cdata( $post->post_type ); ?></wp:post_type>
<wp:post_password><?php echo wxr_cdata( $post->post_password ); ?></wp:post_password> <wp:post_password><?php echo wxr_cdata( $post->post_password ); ?></wp:post_password>
<wp:is_sticky><?php echo intval( $is_sticky ); ?></wp:is_sticky> <wp:is_sticky><?php echo (int) $is_sticky; ?></wp:is_sticky>
<?php if ( 'attachment' === $post->post_type ) : ?> <?php if ( 'attachment' === $post->post_type ) : ?>
<wp:attachment_url><?php echo wxr_cdata( wp_get_attachment_url( $post->ID ) ); ?></wp:attachment_url> <wp:attachment_url><?php echo wxr_cdata( wp_get_attachment_url( $post->ID ) ); ?></wp:attachment_url>
<?php endif; ?> <?php endif; ?>
@ -620,7 +620,7 @@ function export_wp( $args = array() ) {
foreach ( $comments as $c ) : foreach ( $comments as $c ) :
?> ?>
<wp:comment> <wp:comment>
<wp:comment_id><?php echo intval( $c->comment_ID ); ?></wp:comment_id> <wp:comment_id><?php echo (int) $c->comment_ID; ?></wp:comment_id>
<wp:comment_author><?php echo wxr_cdata( $c->comment_author ); ?></wp:comment_author> <wp:comment_author><?php echo wxr_cdata( $c->comment_author ); ?></wp:comment_author>
<wp:comment_author_email><?php echo wxr_cdata( $c->comment_author_email ); ?></wp:comment_author_email> <wp:comment_author_email><?php echo wxr_cdata( $c->comment_author_email ); ?></wp:comment_author_email>
<wp:comment_author_url><?php echo esc_url_raw( $c->comment_author_url ); ?></wp:comment_author_url> <wp:comment_author_url><?php echo esc_url_raw( $c->comment_author_url ); ?></wp:comment_author_url>
@ -630,8 +630,8 @@ function export_wp( $args = array() ) {
<wp:comment_content><?php echo wxr_cdata( $c->comment_content ); ?></wp:comment_content> <wp:comment_content><?php echo wxr_cdata( $c->comment_content ); ?></wp:comment_content>
<wp:comment_approved><?php echo wxr_cdata( $c->comment_approved ); ?></wp:comment_approved> <wp:comment_approved><?php echo wxr_cdata( $c->comment_approved ); ?></wp:comment_approved>
<wp:comment_type><?php echo wxr_cdata( $c->comment_type ); ?></wp:comment_type> <wp:comment_type><?php echo wxr_cdata( $c->comment_type ); ?></wp:comment_type>
<wp:comment_parent><?php echo intval( $c->comment_parent ); ?></wp:comment_parent> <wp:comment_parent><?php echo (int) $c->comment_parent; ?></wp:comment_parent>
<wp:comment_user_id><?php echo intval( $c->user_id ); ?></wp:comment_user_id> <wp:comment_user_id><?php echo (int) $c->user_id; ?></wp:comment_user_id>
<?php <?php
$c_meta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->commentmeta WHERE comment_id = %d", $c->comment_ID ) ); $c_meta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->commentmeta WHERE comment_id = %d", $c->comment_ID ) );
foreach ( $c_meta as $meta ) : foreach ( $c_meta as $meta ) :

View File

@ -510,7 +510,7 @@ function wp_edit_theme_plugin_file( $args ) {
$scrape_key = md5( rand() ); $scrape_key = md5( rand() );
$transient = 'scrape_key_' . $scrape_key; $transient = 'scrape_key_' . $scrape_key;
$scrape_nonce = strval( rand() ); $scrape_nonce = (string) rand();
// It shouldn't take more than 60 seconds to make the two loopback requests. // It shouldn't take more than 60 seconds to make the two loopback requests.
set_transient( $transient, $scrape_nonce, 60 ); set_transient( $transient, $scrape_nonce, 60 );

View File

@ -786,8 +786,8 @@ function wp_save_image( $post_id ) {
return $return; return $return;
} }
$fwidth = ! empty( $_REQUEST['fwidth'] ) ? intval( $_REQUEST['fwidth'] ) : 0; $fwidth = ! empty( $_REQUEST['fwidth'] ) ? (int) $_REQUEST['fwidth'] : 0;
$fheight = ! empty( $_REQUEST['fheight'] ) ? intval( $_REQUEST['fheight'] ) : 0; $fheight = ! empty( $_REQUEST['fheight'] ) ? (int) $_REQUEST['fheight'] : 0;
$target = ! empty( $_REQUEST['target'] ) ? preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['target'] ) : ''; $target = ! empty( $_REQUEST['target'] ) ? preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['target'] ) : '';
$scale = ! empty( $_REQUEST['do'] ) && 'scale' === $_REQUEST['do']; $scale = ! empty( $_REQUEST['do'] ) && 'scale' === $_REQUEST['do'];
@ -944,8 +944,8 @@ function wp_save_image( $post_id ) {
} }
if ( isset( $_wp_additional_image_sizes[ $size ] ) ) { if ( isset( $_wp_additional_image_sizes[ $size ] ) ) {
$width = intval( $_wp_additional_image_sizes[ $size ]['width'] ); $width = (int) $_wp_additional_image_sizes[ $size ]['width'];
$height = intval( $_wp_additional_image_sizes[ $size ]['height'] ); $height = (int) $_wp_additional_image_sizes[ $size ]['height'];
$crop = ( $nocrop ) ? false : $_wp_additional_image_sizes[ $size ]['crop']; $crop = ( $nocrop ) ? false : $_wp_additional_image_sizes[ $size ]['crop'];
} else { } else {
$height = get_option( "{$size}_size_h" ); $height = get_option( "{$size}_size_h" );

View File

@ -49,10 +49,10 @@ function update_gallery_tab( $tabs ) {
return $tabs; return $tabs;
} }
$post_id = intval( $_REQUEST['post_id'] ); $post_id = (int) $_REQUEST['post_id'];
if ( $post_id ) { if ( $post_id ) {
$attachments = intval( $wpdb->get_var( $wpdb->prepare( "SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent = %d", $post_id ) ) ); $attachments = (int) $wpdb->get_var( $wpdb->prepare( "SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent = %d", $post_id ) );
} }
if ( empty( $attachments ) ) { if ( empty( $attachments ) ) {
@ -138,7 +138,7 @@ function get_image_send_to_editor( $id, $caption, $title, $align, $url = '', $re
if ( is_string( $rel ) ) { if ( is_string( $rel ) ) {
$rel = ' rel="' . esc_attr( $rel ) . '"'; $rel = ' rel="' . esc_attr( $rel ) . '"';
} else { } else {
$rel = ' rel="attachment wp-att-' . intval( $id ) . '"'; $rel = ' rel="attachment wp-att-' . (int) $id . '"';
} }
} else { } else {
$rel = ''; $rel = '';
@ -1549,7 +1549,7 @@ function get_media_item( $attachment_id, $args = null ) {
global $redir_tab; global $redir_tab;
$thumb_url = false; $thumb_url = false;
$attachment_id = intval( $attachment_id ); $attachment_id = (int) $attachment_id;
if ( $attachment_id ) { if ( $attachment_id ) {
$thumb_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail', true ); $thumb_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail', true );
@ -2035,7 +2035,7 @@ function get_compat_media_markup( $attachment_id, $args = null ) {
* @since 2.5.0 * @since 2.5.0
*/ */
function media_upload_header() { function media_upload_header() {
$post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0; $post_id = isset( $_REQUEST['post_id'] ) ? (int) $_REQUEST['post_id'] : 0;
echo '<script type="text/javascript">post_id = ' . $post_id . ';</script>'; echo '<script type="text/javascript">post_id = ' . $post_id . ';</script>';
@ -2071,7 +2071,7 @@ function media_upload_form( $errors = null ) {
} }
$upload_action_url = admin_url( 'async-upload.php' ); $upload_action_url = admin_url( 'async-upload.php' );
$post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0; $post_id = isset( $_REQUEST['post_id'] ) ? (int) $_REQUEST['post_id'] : 0;
$_type = isset( $type ) ? $type : ''; $_type = isset( $type ) ? $type : '';
$_tab = isset( $tab ) ? $tab : ''; $_tab = isset( $tab ) ? $tab : '';
@ -2281,7 +2281,7 @@ function media_upload_type_form( $type = 'file', $errors = null, $id = null ) {
media_upload_header(); media_upload_header();
$post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0; $post_id = isset( $_REQUEST['post_id'] ) ? (int) $_REQUEST['post_id'] : 0;
$form_action_url = admin_url( "media-upload.php?type=$type&tab=type&post_id=$post_id" ); $form_action_url = admin_url( "media-upload.php?type=$type&tab=type&post_id=$post_id" );
@ -2358,7 +2358,7 @@ function media_upload_type_url_form( $type = null, $errors = null, $id = null )
media_upload_header(); media_upload_header();
$post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0; $post_id = isset( $_REQUEST['post_id'] ) ? (int) $_REQUEST['post_id'] : 0;
$form_action_url = admin_url( "media-upload.php?type=$type&tab=type&post_id=$post_id" ); $form_action_url = admin_url( "media-upload.php?type=$type&tab=type&post_id=$post_id" );
/** This filter is documented in wp-admin/includes/media.php */ /** This filter is documented in wp-admin/includes/media.php */
@ -2506,7 +2506,7 @@ function media_upload_gallery_form( $errors ) {
$redir_tab = 'gallery'; $redir_tab = 'gallery';
media_upload_header(); media_upload_header();
$post_id = intval( $_REQUEST['post_id'] ); $post_id = (int) $_REQUEST['post_id'];
$form_action_url = admin_url( "media-upload.php?type=$type&tab=gallery&post_id=$post_id" ); $form_action_url = admin_url( "media-upload.php?type=$type&tab=gallery&post_id=$post_id" );
/** This filter is documented in wp-admin/includes/media.php */ /** This filter is documented in wp-admin/includes/media.php */
$form_action_url = apply_filters( 'media_upload_form_url', $form_action_url, $type ); $form_action_url = apply_filters( 'media_upload_form_url', $form_action_url, $type );
@ -2669,7 +2669,7 @@ function media_upload_library_form( $errors ) {
media_upload_header(); media_upload_header();
$post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0; $post_id = isset( $_REQUEST['post_id'] ) ? (int) $_REQUEST['post_id'] : 0;
$form_action_url = admin_url( "media-upload.php?type=$type&tab=library&post_id=$post_id" ); $form_action_url = admin_url( "media-upload.php?type=$type&tab=library&post_id=$post_id" );
/** This filter is documented in wp-admin/includes/media.php */ /** This filter is documented in wp-admin/includes/media.php */
@ -2682,7 +2682,7 @@ function media_upload_library_form( $errors ) {
$q = $_GET; $q = $_GET;
$q['posts_per_page'] = 10; $q['posts_per_page'] = 10;
$q['paged'] = isset( $q['paged'] ) ? intval( $q['paged'] ) : 0; $q['paged'] = isset( $q['paged'] ) ? (int) $q['paged'] : 0;
if ( $q['paged'] < 1 ) { if ( $q['paged'] < 1 ) {
$q['paged'] = 1; $q['paged'] = 1;
} }
@ -2984,9 +2984,9 @@ function media_upload_flash_bypass() {
$post = get_post(); $post = get_post();
if ( $post ) { if ( $post ) {
$browser_uploader .= '&amp;post_id=' . intval( $post->ID ); $browser_uploader .= '&amp;post_id=' . (int) $post->ID;
} elseif ( ! empty( $GLOBALS['post_ID'] ) ) { } elseif ( ! empty( $GLOBALS['post_ID'] ) ) {
$browser_uploader .= '&amp;post_id=' . intval( $GLOBALS['post_ID'] ); $browser_uploader .= '&amp;post_id=' . (int) $GLOBALS['post_ID'];
} }
?> ?>
@ -3078,7 +3078,7 @@ function edit_form_image_editor( $post ) {
} }
$thumb_url = false; $thumb_url = false;
$attachment_id = intval( $post->ID ); $attachment_id = (int) $post->ID;
if ( $attachment_id ) { if ( $attachment_id ) {
$thumb_url = wp_get_attachment_image_src( $attachment_id, array( 900, 450 ), true ); $thumb_url = wp_get_attachment_image_src( $attachment_id, array( 900, 450 ), true );

View File

@ -382,7 +382,7 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
$important_pages[] = $front_page_obj; $important_pages[] = $front_page_obj;
$suppress_page_ids[] = $front_page_obj->ID; $suppress_page_ids[] = $front_page_obj->ID;
} else { } else {
$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval( $_nav_menu_placeholder ) - 1 : -1; $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? (int) $_nav_menu_placeholder - 1 : -1;
$front_page_obj = (object) array( $front_page_obj = (object) array(
'front_or_home' => true, 'front_or_home' => true,
'ID' => 0, 'ID' => 0,
@ -609,7 +609,7 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
$args['walker'] = $walker; $args['walker'] = $walker;
if ( $post_type->has_archive ) { if ( $post_type->has_archive ) {
$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval( $_nav_menu_placeholder ) - 1 : -1; $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? (int) $_nav_menu_placeholder - 1 : -1;
array_unshift( array_unshift(
$posts, $posts,
(object) array( (object) array(

View File

@ -1347,10 +1347,11 @@ function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $func
if ( null === $position ) { if ( null === $position ) {
$menu[] = $new_menu; $menu[] = $new_menu;
} elseif ( isset( $menu[ "$position" ] ) ) {
$position = $position + substr( base_convert( md5( $menu_slug . $menu_title ), 16, 10 ), -5 ) * 0.00001;
$menu[ "$position" ] = $new_menu;
} else { } else {
if ( isset( $menu[ $position ] ) ) {
$position = $position + substr( base_convert( md5( $menu_slug . $menu_title ), 16, 10 ), -5 ) * 0.00001;
}
$menu[ $position ] = $new_menu; $menu[ $position ] = $new_menu;
} }

View File

@ -1923,7 +1923,7 @@ function post_preview() {
} }
if ( isset( $_POST['_thumbnail_id'] ) ) { if ( isset( $_POST['_thumbnail_id'] ) ) {
$query_args['_thumbnail_id'] = ( intval( $_POST['_thumbnail_id'] ) <= 0 ) ? '-1' : intval( $_POST['_thumbnail_id'] ); $query_args['_thumbnail_id'] = ( (int) $_POST['_thumbnail_id'] <= 0 ) ? '-1' : (int) $_POST['_thumbnail_id'];
} }
} }
@ -2085,7 +2085,7 @@ function taxonomy_meta_box_sanitize_cb_input( $taxonomy, $terms ) {
); );
if ( ! empty( $_term ) ) { if ( ! empty( $_term ) ) {
$clean_terms[] = intval( $_term[0] ); $clean_terms[] = (int) $_term[0];
} else { } else {
// No existing term was found, so pass the string. A new term will be created. // No existing term was found, so pass the string. A new term will be created.
$clean_terms[] = $term; $clean_terms[] = $term;

View File

@ -1321,7 +1321,7 @@ function do_meta_boxes( $screen, $context, $object ) {
echo '<span aria-hidden="true" class="dashicons dashicons-warning"></span>'; echo '<span aria-hidden="true" class="dashicons dashicons-warning"></span>';
echo '<span class="screen-reader-text">' . __( 'Warning:' ) . ' </span>'; echo '<span class="screen-reader-text">' . __( 'Warning:' ) . ' </span>';
} }
echo "{$box['title']}"; echo $box['title'];
echo "</h2>\n"; echo "</h2>\n";
if ( 'dashboard_browser_nag' !== $box['id'] ) { if ( 'dashboard_browser_nag' !== $box['id'] ) {
@ -2205,16 +2205,16 @@ function get_post_states( $post ) {
} }
if ( 'page' === get_option( 'show_on_front' ) ) { if ( 'page' === get_option( 'show_on_front' ) ) {
if ( intval( get_option( 'page_on_front' ) ) === $post->ID ) { if ( (int) get_option( 'page_on_front' ) === $post->ID ) {
$post_states['page_on_front'] = _x( 'Front Page', 'page label' ); $post_states['page_on_front'] = _x( 'Front Page', 'page label' );
} }
if ( intval( get_option( 'page_for_posts' ) ) === $post->ID ) { if ( (int) get_option( 'page_for_posts' ) === $post->ID ) {
$post_states['page_for_posts'] = _x( 'Posts Page', 'page label' ); $post_states['page_for_posts'] = _x( 'Posts Page', 'page label' );
} }
} }
if ( intval( get_option( 'wp_page_for_privacy_policy' ) ) === $post->ID ) { if ( (int) get_option( 'wp_page_for_privacy_policy' ) === $post->ID ) {
$post_states['page_for_privacy_policy'] = _x( 'Privacy Policy Page', 'page label' ); $post_states['page_for_privacy_policy'] = _x( 'Privacy Policy Page', 'page label' );
} }

View File

@ -1059,7 +1059,7 @@ function wp_get_auto_update_message() {
if ( false === $next_update_time ) { if ( false === $next_update_time ) {
$message = __( 'Automatic update not scheduled. There may be a problem with WP-Cron.' ); $message = __( 'Automatic update not scheduled. There may be a problem with WP-Cron.' );
} else { } else {
$time_to_next_update = human_time_diff( intval( $next_update_time ) ); $time_to_next_update = human_time_diff( (int) $next_update_time );
// See if cron is overdue. // See if cron is overdue.
$overdue = ( time() - $next_update_time ) > 0; $overdue = ( time() - $next_update_time ) > 0;

View File

@ -1022,8 +1022,8 @@ function upgrade_110() {
if ( ! $got_gmt_fields ) { if ( ! $got_gmt_fields ) {
// Add or subtract time to all dates, to get GMT dates. // Add or subtract time to all dates, to get GMT dates.
$add_hours = intval( $diff_gmt_weblogger ); $add_hours = (int) $diff_gmt_weblogger;
$add_minutes = intval( 60 * ( $diff_gmt_weblogger - $add_hours ) ); $add_minutes = (int) ( 60 * ( $diff_gmt_weblogger - $add_hours ) );
$wpdb->query( "UPDATE $wpdb->posts SET post_date_gmt = DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)" ); $wpdb->query( "UPDATE $wpdb->posts SET post_date_gmt = DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)" );
$wpdb->query( "UPDATE $wpdb->posts SET post_modified = post_date" ); $wpdb->query( "UPDATE $wpdb->posts SET post_modified = post_date" );
$wpdb->query( "UPDATE $wpdb->posts SET post_modified_gmt = DATE_ADD(post_modified, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE) WHERE post_modified != '0000-00-00 00:00:00'" ); $wpdb->query( "UPDATE $wpdb->posts SET post_modified_gmt = DATE_ADD(post_modified, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE) WHERE post_modified != '0000-00-00 00:00:00'" );
@ -2048,7 +2048,7 @@ function upgrade_430_fix_comments() {
return; return;
} }
$allowed_length = intval( $content_length['length'] ) - 10; $allowed_length = (int) $content_length['length'] - 10;
$comments = $wpdb->get_results( $comments = $wpdb->get_results(
"SELECT `comment_ID` FROM `{$wpdb->comments}` "SELECT `comment_ID` FROM `{$wpdb->comments}`

View File

@ -51,7 +51,7 @@ if ( ! empty( $_REQUEST['post_id'] ) && ! current_user_can( 'edit_post', $_REQUE
// Upload type: image, video, file, ...? // Upload type: image, video, file, ...?
if ( isset( $_GET['type'] ) ) { if ( isset( $_GET['type'] ) ) {
$type = strval( $_GET['type'] ); $type = (string) $_GET['type'];
} else { } else {
/** /**
* Filters the default media upload type in the legacy (pre-3.5.0) media popup. * Filters the default media upload type in the legacy (pre-3.5.0) media popup.
@ -66,7 +66,7 @@ if ( isset( $_GET['type'] ) ) {
// Tab: gallery, library, or type-specific. // Tab: gallery, library, or type-specific.
if ( isset( $_GET['tab'] ) ) { if ( isset( $_GET['tab'] ) ) {
$tab = strval( $_GET['tab'] ); $tab = (string) $_GET['tab'];
} else { } else {
/** /**
* Filters the default tab in the legacy (pre-3.5.0) media popup. * Filters the default tab in the legacy (pre-3.5.0) media popup.

View File

@ -424,7 +424,7 @@ switch ( $action ) {
// If the menu ID changed, redirect to the new URL. // If the menu ID changed, redirect to the new URL.
if ( $nav_menu_selected_id !== $_nav_menu_selected_id ) { if ( $nav_menu_selected_id !== $_nav_menu_selected_id ) {
wp_redirect( admin_url( 'nav-menus.php?menu=' . intval( $_nav_menu_selected_id ) ) ); wp_redirect( admin_url( 'nav-menus.php?menu=' . (int) $_nav_menu_selected_id ) );
exit; exit;
} }
} }

View File

@ -17,7 +17,7 @@ if ( ! current_user_can( 'manage_sites' ) ) {
get_current_screen()->add_help_tab( get_site_screen_help_tab_args() ); get_current_screen()->add_help_tab( get_site_screen_help_tab_args() );
get_current_screen()->set_help_sidebar( get_site_screen_help_sidebar_content() ); get_current_screen()->set_help_sidebar( get_site_screen_help_sidebar_content() );
$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; $id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0;
if ( ! $id ) { if ( ! $id ) {
wp_die( __( 'Invalid site ID.' ) ); wp_die( __( 'Invalid site ID.' ) );

View File

@ -17,7 +17,7 @@ if ( ! current_user_can( 'manage_sites' ) ) {
get_current_screen()->add_help_tab( get_site_screen_help_tab_args() ); get_current_screen()->add_help_tab( get_site_screen_help_tab_args() );
get_current_screen()->set_help_sidebar( get_site_screen_help_sidebar_content() ); get_current_screen()->set_help_sidebar( get_site_screen_help_sidebar_content() );
$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; $id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0;
if ( ! $id ) { if ( ! $id ) {
wp_die( __( 'Invalid site ID.' ) ); wp_die( __( 'Invalid site ID.' ) );

View File

@ -40,7 +40,7 @@ if ( ! empty( $_REQUEST['paged'] ) ) {
$referer = add_query_arg( 'paged', (int) $_REQUEST['paged'], $referer ); $referer = add_query_arg( 'paged', (int) $_REQUEST['paged'], $referer );
} }
$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; $id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0;
if ( ! $id ) { if ( ! $id ) {
wp_die( __( 'Invalid site ID.' ) ); wp_die( __( 'Invalid site ID.' ) );

View File

@ -35,7 +35,7 @@ if ( ! empty( $_REQUEST['paged'] ) ) {
$referer = add_query_arg( 'paged', (int) $_REQUEST['paged'], $referer ); $referer = add_query_arg( 'paged', (int) $_REQUEST['paged'], $referer );
} }
$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; $id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0;
if ( ! $id ) { if ( ! $id ) {
wp_die( __( 'Invalid site ID.' ) ); wp_die( __( 'Invalid site ID.' ) );

View File

@ -53,7 +53,7 @@ get_current_screen()->set_screen_reader_content(
) )
); );
$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; $id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0;
if ( isset( $_GET['action'] ) ) { if ( isset( $_GET['action'] ) ) {
/** This action is documented in wp-admin/network/edit.php */ /** This action is documented in wp-admin/network/edit.php */

View File

@ -45,7 +45,7 @@ $action = isset( $_GET['action'] ) ? $_GET['action'] : 'show';
switch ( $action ) { switch ( $action ) {
case 'upgrade': case 'upgrade':
$n = ( isset( $_GET['n'] ) ) ? intval( $_GET['n'] ) : 0; $n = ( isset( $_GET['n'] ) ) ? (int) $_GET['n'] : 0;
if ( $n < 5 ) { if ( $n < 5 ) {
/** /**

View File

@ -26,7 +26,7 @@ if ( isset( $_GET['action'] ) ) {
check_admin_referer( 'deleteuser' ); check_admin_referer( 'deleteuser' );
$id = intval( $_GET['id'] ); $id = (int) $_GET['id'];
if ( $id > 1 ) { if ( $id > 1 ) {
$_POST['allusers'] = array( $id ); // confirm_delete_users() can only handle arrays. $_POST['allusers'] = array( $id ); // confirm_delete_users() can only handle arrays.
$title = __( 'Users' ); $title = __( 'Users' );

View File

@ -230,7 +230,7 @@ switch ( $wp_list_table->current_action() ) {
} }
if ( empty( $_REQUEST['users'] ) ) { if ( empty( $_REQUEST['users'] ) ) {
$userids = array( intval( $_REQUEST['user'] ) ); $userids = array( (int) $_REQUEST['user'] );
} else { } else {
$userids = array_map( 'intval', (array) $_REQUEST['users'] ); $userids = array_map( 'intval', (array) $_REQUEST['users'] );
} }
@ -401,7 +401,7 @@ switch ( $wp_list_table->current_action() ) {
} }
if ( empty( $_REQUEST['users'] ) ) { if ( empty( $_REQUEST['users'] ) ) {
$userids = array( intval( $_REQUEST['user'] ) ); $userids = array( (int) $_REQUEST['user'] );
} else { } else {
$userids = $_REQUEST['users']; $userids = $_REQUEST['users'];
} }

View File

@ -24,7 +24,7 @@ nocache_headers();
$comment = wp_handle_comment_submission( wp_unslash( $_POST ) ); $comment = wp_handle_comment_submission( wp_unslash( $_POST ) );
if ( is_wp_error( $comment ) ) { if ( is_wp_error( $comment ) ) {
$data = intval( $comment->get_error_data() ); $data = (int) $comment->get_error_data();
if ( ! empty( $data ) ) { if ( ! empty( $data ) ) {
wp_die( wp_die(
'<p>' . $comment->get_error_message() . '</p>', '<p>' . $comment->get_error_message() . '</p>',

View File

@ -24,7 +24,7 @@ if ( ! function_exists( 'twentyfourteen_paging_nav' ) ) :
return; return;
} }
$paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1; $paged = get_query_var( 'paged' ) ? (int) get_query_var( 'paged' ) : 1;
$pagenum_link = html_entity_decode( get_pagenum_link() ); $pagenum_link = html_entity_decode( get_pagenum_link() );
$query_args = array(); $query_args = array();
$url_parts = explode( '?', $pagenum_link ); $url_parts = explode( '?', $pagenum_link );

View File

@ -433,7 +433,7 @@ function wp_dropdown_categories( $args = '' ) {
/** This filter is documented in wp-includes/category-template.php */ /** This filter is documented in wp-includes/category-template.php */
$show_option_all = apply_filters( 'list_cats', $parsed_args['show_option_all'], null ); $show_option_all = apply_filters( 'list_cats', $parsed_args['show_option_all'], null );
$selected = ( '0' === strval( $parsed_args['selected'] ) ) ? " selected='selected'" : ''; $selected = ( '0' === (string) $parsed_args['selected'] ) ? " selected='selected'" : '';
$output .= "\t<option value='0'$selected>$show_option_all</option>\n"; $output .= "\t<option value='0'$selected>$show_option_all</option>\n";
} }
@ -737,7 +737,7 @@ function wp_tag_cloud( $args = '' ) {
if ( 'edit' === $args['link'] ) { if ( 'edit' === $args['link'] ) {
$link = get_edit_term_link( $tag->term_id, $tag->taxonomy, $args['post_type'] ); $link = get_edit_term_link( $tag->term_id, $tag->taxonomy, $args['post_type'] );
} else { } else {
$link = get_term_link( intval( $tag->term_id ), $tag->taxonomy ); $link = get_term_link( (int) $tag->term_id, $tag->taxonomy );
} }
if ( is_wp_error( $link ) ) { if ( is_wp_error( $link ) ) {

View File

@ -752,7 +752,7 @@ class WP_Http {
} }
// Cast the Response Code to an int. // Cast the Response Code to an int.
$response['code'] = intval( $response['code'] ); $response['code'] = (int) $response['code'];
return array( return array(
'response' => $response, 'response' => $response,

View File

@ -579,7 +579,7 @@ class Services_JSON
return $encoded_value; return $encoded_value;
} }
return $this->_encode(strval($name)) . ':' . $encoded_value; return $this->_encode((string) $name) . ':' . $encoded_value;
} }
/** /**

View File

@ -456,7 +456,7 @@ class WP_Comment_Query {
// If querying for a count only, there's nothing more to do. // If querying for a count only, there's nothing more to do.
if ( $this->query_vars['count'] ) { if ( $this->query_vars['count'] ) {
// $comment_ids is actually a count in this case. // $comment_ids is actually a count in this case.
return intval( $comment_ids ); return (int) $comment_ids;
} }
$comment_ids = array_map( 'intval', $comment_ids ); $comment_ids = array_map( 'intval', $comment_ids );
@ -942,7 +942,7 @@ class WP_Comment_Query {
$this->request = "{$this->sql_clauses['select']} {$this->sql_clauses['from']} {$where} {$this->sql_clauses['groupby']} {$this->sql_clauses['orderby']} {$this->sql_clauses['limits']}"; $this->request = "{$this->sql_clauses['select']} {$this->sql_clauses['from']} {$where} {$this->sql_clauses['groupby']} {$this->sql_clauses['orderby']} {$this->sql_clauses['limits']}";
if ( $this->query_vars['count'] ) { if ( $this->query_vars['count'] ) {
return intval( $wpdb->get_var( $this->request ) ); return (int) $wpdb->get_var( $this->request );
} else { } else {
$comment_ids = $wpdb->get_col( $this->request ); $comment_ids = $wpdb->get_col( $this->request );
return array_map( 'intval', $comment_ids ); return array_map( 'intval', $comment_ids );

View File

@ -1463,7 +1463,7 @@ final class WP_Customize_Manager {
preg_match( '#^nav_menu\[(?P<nav_menu_id>-?\d+)\]$#', $setting_id, $matches ) preg_match( '#^nav_menu\[(?P<nav_menu_id>-?\d+)\]$#', $setting_id, $matches )
); );
if ( $can_reuse ) { if ( $can_reuse ) {
$nav_menu_term_id = intval( $matches['nav_menu_id'] ); $nav_menu_term_id = (int) $matches['nav_menu_id'];
$nav_menu_setting_id = $setting_id; $nav_menu_setting_id = $setting_id;
$reused_nav_menu_setting_ids[] = $setting_id; $reused_nav_menu_setting_ids[] = $setting_id;
break; break;
@ -3268,7 +3268,7 @@ final class WP_Customize_Manager {
$lock = explode( ':', $lock ); $lock = explode( ':', $lock );
if ( $lock && ! empty( $lock[1] ) ) { if ( $lock && ! empty( $lock[1] ) ) {
$user_id = intval( $lock[1] ); $user_id = (int) $lock[1];
$current_user_id = get_current_user_id(); $current_user_id = get_current_user_id();
if ( $user_id === $current_user_id ) { if ( $user_id === $current_user_id ) {
$lock = sprintf( '%s:%s', time(), $user_id ); $lock = sprintf( '%s:%s', time(), $user_id );

View File

@ -249,8 +249,8 @@ final class WP_Customize_Nav_Menus {
'type' => 'post_type', 'type' => 'post_type',
'type_label' => $post_type_label, 'type_label' => $post_type_label,
'object' => $post->post_type, 'object' => $post->post_type,
'object_id' => intval( $post->ID ), 'object_id' => (int) $post->ID,
'url' => get_permalink( intval( $post->ID ) ), 'url' => get_permalink( (int) $post->ID ),
); );
} }
} elseif ( 'taxonomy' === $type ) { } elseif ( 'taxonomy' === $type ) {
@ -281,8 +281,8 @@ final class WP_Customize_Nav_Menus {
'type' => 'taxonomy', 'type' => 'taxonomy',
'type_label' => get_taxonomy( $term->taxonomy )->labels->singular_name, 'type_label' => get_taxonomy( $term->taxonomy )->labels->singular_name,
'object' => $term->taxonomy, 'object' => $term->taxonomy,
'object_id' => intval( $term->term_id ), 'object_id' => (int) $term->term_id,
'url' => get_term_link( intval( $term->term_id ), $term->taxonomy ), 'url' => get_term_link( (int) $term->term_id, $term->taxonomy ),
); );
} }
} }
@ -410,8 +410,8 @@ final class WP_Customize_Nav_Menus {
'type' => 'post_type', 'type' => 'post_type',
'type_label' => $post_type_label, 'type_label' => $post_type_label,
'object' => $post->post_type, 'object' => $post->post_type,
'object_id' => intval( $post->ID ), 'object_id' => (int) $post->ID,
'url' => get_permalink( intval( $post->ID ) ), 'url' => get_permalink( (int) $post->ID ),
); );
} }
@ -436,8 +436,8 @@ final class WP_Customize_Nav_Menus {
'type' => 'taxonomy', 'type' => 'taxonomy',
'type_label' => get_taxonomy( $term->taxonomy )->labels->singular_name, 'type_label' => get_taxonomy( $term->taxonomy )->labels->singular_name,
'object' => $term->taxonomy, 'object' => $term->taxonomy,
'object_id' => intval( $term->term_id ), 'object_id' => (int) $term->term_id,
'url' => get_term_link( intval( $term->term_id ), $term->taxonomy ), 'url' => get_term_link( (int) $term->term_id, $term->taxonomy ),
); );
} }
} }

View File

@ -605,7 +605,7 @@ final class WP_Customize_Widgets {
if ( preg_match( '/^(.+)-(\d+)$/', $widget_id, $matches ) ) { if ( preg_match( '/^(.+)-(\d+)$/', $widget_id, $matches ) ) {
$parsed['id_base'] = $matches[1]; $parsed['id_base'] = $matches[1];
$parsed['number'] = intval( $matches[2] ); $parsed['number'] = (int) $matches[2];
} else { } else {
// Likely an old single widget. // Likely an old single widget.
$parsed['id_base'] = $widget_id; $parsed['id_base'] = $widget_id;
@ -628,7 +628,7 @@ final class WP_Customize_Widgets {
} }
$id_base = $matches[2]; $id_base = $matches[2];
$number = isset( $matches[3] ) ? intval( $matches[3] ) : null; $number = isset( $matches[3] ) ? (int) $matches[3] : null;
return compact( 'id_base', 'number' ); return compact( 'id_base', 'number' );
} }
@ -1772,7 +1772,7 @@ final class WP_Customize_Widgets {
} }
$this->sidebar_instance_count[ $index ] += 1; $this->sidebar_instance_count[ $index ] += 1;
if ( ! $this->manager->selective_refresh->is_render_partials_request() ) { if ( ! $this->manager->selective_refresh->is_render_partials_request() ) {
printf( "\n<!--dynamic_sidebar_before:%s:%d-->\n", esc_html( $index ), intval( $this->sidebar_instance_count[ $index ] ) ); printf( "\n<!--dynamic_sidebar_before:%s:%d-->\n", esc_html( $index ), (int) $this->sidebar_instance_count[ $index ] );
} }
} }
@ -1788,7 +1788,7 @@ final class WP_Customize_Widgets {
public function end_dynamic_sidebar( $index ) { public function end_dynamic_sidebar( $index ) {
array_shift( $this->current_dynamic_sidebar_id_stack ); array_shift( $this->current_dynamic_sidebar_id_stack );
if ( ! $this->manager->selective_refresh->is_render_partials_request() ) { if ( ! $this->manager->selective_refresh->is_render_partials_request() ) {
printf( "\n<!--dynamic_sidebar_after:%s:%d-->\n", esc_html( $index ), intval( $this->sidebar_instance_count[ $index ] ) ); printf( "\n<!--dynamic_sidebar_after:%s:%d-->\n", esc_html( $index ), (int) $this->sidebar_instance_count[ $index ] );
} }
} }
@ -1851,7 +1851,7 @@ final class WP_Customize_Widgets {
$this->rendering_sidebar_id = $context['sidebar_id']; $this->rendering_sidebar_id = $context['sidebar_id'];
if ( isset( $context['sidebar_instance_number'] ) ) { if ( isset( $context['sidebar_instance_number'] ) ) {
$this->context_sidebar_instance_number = intval( $context['sidebar_instance_number'] ); $this->context_sidebar_instance_number = (int) $context['sidebar_instance_number'];
} }
// Filter sidebars_widgets so that only the queried widget is in the sidebar. // Filter sidebars_widgets so that only the queried widget is in the sidebar.

View File

@ -874,32 +874,32 @@ class WP_Date_Query {
if ( preg_match( '/^(\d{4})$/', $datetime, $matches ) ) { if ( preg_match( '/^(\d{4})$/', $datetime, $matches ) ) {
// Y // Y
$datetime = array( $datetime = array(
'year' => intval( $matches[1] ), 'year' => (int) $matches[1],
); );
} elseif ( preg_match( '/^(\d{4})\-(\d{2})$/', $datetime, $matches ) ) { } elseif ( preg_match( '/^(\d{4})\-(\d{2})$/', $datetime, $matches ) ) {
// Y-m // Y-m
$datetime = array( $datetime = array(
'year' => intval( $matches[1] ), 'year' => (int) $matches[1],
'month' => intval( $matches[2] ), 'month' => (int) $matches[2],
); );
} elseif ( preg_match( '/^(\d{4})\-(\d{2})\-(\d{2})$/', $datetime, $matches ) ) { } elseif ( preg_match( '/^(\d{4})\-(\d{2})\-(\d{2})$/', $datetime, $matches ) ) {
// Y-m-d // Y-m-d
$datetime = array( $datetime = array(
'year' => intval( $matches[1] ), 'year' => (int) $matches[1],
'month' => intval( $matches[2] ), 'month' => (int) $matches[2],
'day' => intval( $matches[3] ), 'day' => (int) $matches[3],
); );
} elseif ( preg_match( '/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2})$/', $datetime, $matches ) ) { } elseif ( preg_match( '/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2})$/', $datetime, $matches ) ) {
// Y-m-d H:i // Y-m-d H:i
$datetime = array( $datetime = array(
'year' => intval( $matches[1] ), 'year' => (int) $matches[1],
'month' => intval( $matches[2] ), 'month' => (int) $matches[2],
'day' => intval( $matches[3] ), 'day' => (int) $matches[3],
'hour' => intval( $matches[4] ), 'hour' => (int) $matches[4],
'minute' => intval( $matches[5] ), 'minute' => (int) $matches[5],
); );
} }

View File

@ -173,7 +173,7 @@ class WP_Http_Curl {
curl_setopt( $handle, CURLOPT_HEADER, false ); curl_setopt( $handle, CURLOPT_HEADER, false );
if ( isset( $parsed_args['limit_response_size'] ) ) { if ( isset( $parsed_args['limit_response_size'] ) ) {
$this->max_body_length = intval( $parsed_args['limit_response_size'] ); $this->max_body_length = (int) $parsed_args['limit_response_size'];
} else { } else {
$this->max_body_length = false; $this->max_body_length = false;
} }

View File

@ -83,7 +83,7 @@ class WP_MatchesMapRegex {
* @return string * @return string
*/ */
public function callback( $matches ) { public function callback( $matches ) {
$index = intval( substr( $matches[0], 9, -1 ) ); $index = (int) substr( $matches[0], 9, -1 );
return ( isset( $this->_matches[ $index ] ) ? urlencode( $this->_matches[ $index ] ) : '' ); return ( isset( $this->_matches[ $index ] ) ? urlencode( $this->_matches[ $index ] ) : '' );
} }
} }

View File

@ -260,7 +260,7 @@ class WP_Network_Query {
// If querying for a count only, there's nothing more to do. // If querying for a count only, there's nothing more to do.
if ( $this->query_vars['count'] ) { if ( $this->query_vars['count'] ) {
// $network_ids is actually a count in this case. // $network_ids is actually a count in this case.
return intval( $network_ids ); return (int) $network_ids;
} }
$network_ids = array_map( 'intval', $network_ids ); $network_ids = array_map( 'intval', $network_ids );
@ -469,7 +469,7 @@ class WP_Network_Query {
$this->request = "{$this->sql_clauses['select']} {$this->sql_clauses['from']} {$where} {$this->sql_clauses['groupby']} {$this->sql_clauses['orderby']} {$this->sql_clauses['limits']}"; $this->request = "{$this->sql_clauses['select']} {$this->sql_clauses['from']} {$where} {$this->sql_clauses['groupby']} {$this->sql_clauses['orderby']} {$this->sql_clauses['limits']}";
if ( $this->query_vars['count'] ) { if ( $this->query_vars['count'] ) {
return intval( $wpdb->get_var( $this->request ) ); return (int) $wpdb->get_var( $this->request );
} }
$network_ids = $wpdb->get_col( $this->request ); $network_ids = $wpdb->get_col( $this->request );

View File

@ -763,7 +763,7 @@ class WP_Query {
$qv['p'] = 0; $qv['p'] = 0;
$qv['error'] = '404'; $qv['error'] = '404';
} else { } else {
$qv['p'] = intval( $qv['p'] ); $qv['p'] = (int) $qv['p'];
} }
$qv['page_id'] = absint( $qv['page_id'] ); $qv['page_id'] = absint( $qv['page_id'] );
@ -942,7 +942,7 @@ class WP_Query {
$this->is_trackback = true; $this->is_trackback = true;
} }
if ( '' != $qv['paged'] && ( intval( $qv['paged'] ) > 1 ) ) { if ( '' != $qv['paged'] && ( (int) $qv['paged'] > 1 ) ) {
$this->is_paged = true; $this->is_paged = true;
} }
@ -1604,7 +1604,7 @@ class WP_Query {
// If RAND() contains a seed value, sanitize and add to allowed keys. // If RAND() contains a seed value, sanitize and add to allowed keys.
$rand_with_seed = false; $rand_with_seed = false;
if ( preg_match( '/RAND\(([0-9]+)\)/i', $orderby, $matches ) ) { if ( preg_match( '/RAND\(([0-9]+)\)/i', $orderby, $matches ) ) {
$orderby = sprintf( 'RAND(%s)', intval( $matches[1] ) ); $orderby = sprintf( 'RAND(%s)', (int) $matches[1] );
$allowed_keys[] = $orderby; $allowed_keys[] = $orderby;
$rand_with_seed = true; $rand_with_seed = true;
} }
@ -2263,7 +2263,7 @@ class WP_Query {
// Numeric comment count is converted to array format. // Numeric comment count is converted to array format.
if ( is_numeric( $q['comment_count'] ) ) { if ( is_numeric( $q['comment_count'] ) ) {
$q['comment_count'] = array( $q['comment_count'] = array(
'value' => intval( $q['comment_count'] ), 'value' => (int) $q['comment_count'],
); );
} }

View File

@ -351,7 +351,7 @@ class WP_Site_Query {
// If querying for a count only, there's nothing more to do. // If querying for a count only, there's nothing more to do.
if ( $this->query_vars['count'] ) { if ( $this->query_vars['count'] ) {
// $site_ids is actually a count in this case. // $site_ids is actually a count in this case.
return intval( $site_ids ); return (int) $site_ids;
} }
$site_ids = array_map( 'intval', $site_ids ); $site_ids = array_map( 'intval', $site_ids );
@ -660,7 +660,7 @@ class WP_Site_Query {
$this->request = "{$this->sql_clauses['select']} {$this->sql_clauses['from']} {$where} {$this->sql_clauses['groupby']} {$this->sql_clauses['orderby']} {$this->sql_clauses['limits']}"; $this->request = "{$this->sql_clauses['select']} {$this->sql_clauses['from']} {$where} {$this->sql_clauses['groupby']} {$this->sql_clauses['orderby']} {$this->sql_clauses['limits']}";
if ( $this->query_vars['count'] ) { if ( $this->query_vars['count'] ) {
return intval( $wpdb->get_var( $this->request ) ); return (int) $wpdb->get_var( $this->request );
} }
$site_ids = $wpdb->get_col( $this->request ); $site_ids = $wpdb->get_col( $this->request );

View File

@ -258,7 +258,7 @@ class WP_Term_Query {
$query['offset'] = absint( $query['offset'] ); $query['offset'] = absint( $query['offset'] );
// 'parent' overrides 'child_of'. // 'parent' overrides 'child_of'.
if ( 0 < intval( $query['parent'] ) ) { if ( 0 < (int) $query['parent'] ) {
$query['child_of'] = false; $query['child_of'] = false;
} }
@ -346,7 +346,7 @@ class WP_Term_Query {
} }
// 'parent' overrides 'child_of'. // 'parent' overrides 'child_of'.
if ( 0 < intval( $args['parent'] ) ) { if ( 0 < (int) $args['parent'] ) {
$args['child_of'] = false; $args['child_of'] = false;
} }
@ -443,7 +443,7 @@ class WP_Term_Query {
(array) get_terms( (array) get_terms(
array( array(
'taxonomy' => reset( $taxonomies ), 'taxonomy' => reset( $taxonomies ),
'child_of' => intval( $extrunk ), 'child_of' => (int) $extrunk,
'fields' => 'ids', 'fields' => 'ids',
'hide_empty' => 0, 'hide_empty' => 0,
) )

View File

@ -199,7 +199,7 @@ class WP_User {
if ( ! is_numeric( $value ) ) { if ( ! is_numeric( $value ) ) {
return false; return false;
} }
$value = intval( $value ); $value = (int) $value;
if ( $value < 1 ) { if ( $value < 1 ) {
return false; return false;
} }
@ -645,7 +645,7 @@ class WP_User {
*/ */
public function level_reduction( $max, $item ) { public function level_reduction( $max, $item ) {
if ( preg_match( '/^level_(10|[0-9])$/i', $item, $matches ) ) { if ( preg_match( '/^level_(10|[0-9])$/i', $item, $matches ) ) {
$level = intval( $matches[1] ); $level = (int) $matches[1];
return max( $max, $level ); return max( $max, $level );
} else { } else {
return $max; return $max;

View File

@ -798,13 +798,13 @@ class wp_xmlrpc_server extends IXR_Server {
} }
// For integers which may be larger than XML-RPC supports ensure we return strings. // For integers which may be larger than XML-RPC supports ensure we return strings.
$_term['term_id'] = strval( $_term['term_id'] ); $_term['term_id'] = (string) $_term['term_id'];
$_term['term_group'] = strval( $_term['term_group'] ); $_term['term_group'] = (string) $_term['term_group'];
$_term['term_taxonomy_id'] = strval( $_term['term_taxonomy_id'] ); $_term['term_taxonomy_id'] = (string) $_term['term_taxonomy_id'];
$_term['parent'] = strval( $_term['parent'] ); $_term['parent'] = (string) $_term['parent'];
// Count we are happy to return as an integer because people really shouldn't use terms that much. // Count we are happy to return as an integer because people really shouldn't use terms that much.
$_term['count'] = intval( $_term['count'] ); $_term['count'] = (int) $_term['count'];
// Get term meta. // Get term meta.
$_term['custom_fields'] = $this->get_term_custom_fields( $_term['term_id'] ); $_term['custom_fields'] = $this->get_term_custom_fields( $_term['term_id'] );
@ -856,7 +856,7 @@ class wp_xmlrpc_server extends IXR_Server {
*/ */
protected function _prepare_post( $post, $fields ) { protected function _prepare_post( $post, $fields ) {
// Holds the data for this post. built up based on $fields. // Holds the data for this post. built up based on $fields.
$_post = array( 'post_id' => strval( $post['ID'] ) ); $_post = array( 'post_id' => (string) $post['ID'] );
// Prepare common post fields. // Prepare common post fields.
$post_fields = array( $post_fields = array(
@ -872,11 +872,11 @@ class wp_xmlrpc_server extends IXR_Server {
'post_password' => $post['post_password'], 'post_password' => $post['post_password'],
'post_excerpt' => $post['post_excerpt'], 'post_excerpt' => $post['post_excerpt'],
'post_content' => $post['post_content'], 'post_content' => $post['post_content'],
'post_parent' => strval( $post['post_parent'] ), 'post_parent' => (string) $post['post_parent'],
'post_mime_type' => $post['post_mime_type'], 'post_mime_type' => $post['post_mime_type'],
'link' => get_permalink( $post['ID'] ), 'link' => get_permalink( $post['ID'] ),
'guid' => $post['guid'], 'guid' => $post['guid'],
'menu_order' => intval( $post['menu_order'] ), 'menu_order' => (int) $post['menu_order'],
'comment_status' => $post['comment_status'], 'comment_status' => $post['comment_status'],
'ping_status' => $post['ping_status'], 'ping_status' => $post['ping_status'],
'sticky' => ( 'post' === $post['post_type'] && is_sticky( $post['ID'] ) ), 'sticky' => ( 'post' === $post['post_type'] && is_sticky( $post['ID'] ) ),
@ -1009,7 +1009,7 @@ class wp_xmlrpc_server extends IXR_Server {
*/ */
protected function _prepare_media_item( $media_item, $thumbnail_size = 'thumbnail' ) { protected function _prepare_media_item( $media_item, $thumbnail_size = 'thumbnail' ) {
$_media_item = array( $_media_item = array(
'attachment_id' => strval( $media_item->ID ), 'attachment_id' => (string) $media_item->ID,
'date_created_gmt' => $this->_convert_date_gmt( $media_item->post_date_gmt, $media_item->post_date ), 'date_created_gmt' => $this->_convert_date_gmt( $media_item->post_date_gmt, $media_item->post_date ),
'parent' => $media_item->post_parent, 'parent' => $media_item->post_parent,
'link' => wp_get_attachment_url( $media_item->ID ), 'link' => wp_get_attachment_url( $media_item->ID ),
@ -1174,7 +1174,7 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array The prepared user data. * @return array The prepared user data.
*/ */
protected function _prepare_user( $user, $fields ) { protected function _prepare_user( $user, $fields ) {
$_user = array( 'user_id' => strval( $user->ID ) ); $_user = array( 'user_id' => (string) $user->ID );
$user_fields = array( $user_fields = array(
'username' => $user->user_login, 'username' => $user->user_login,
@ -1647,7 +1647,7 @@ class wp_xmlrpc_server extends IXR_Server {
} }
} }
return strval( $post_ID ); return (string) $post_ID;
} }
/** /**
@ -2094,7 +2094,7 @@ class wp_xmlrpc_server extends IXR_Server {
$this->set_term_custom_fields( $term['term_id'], $content_struct['custom_fields'] ); $this->set_term_custom_fields( $term['term_id'], $content_struct['custom_fields'] );
} }
return strval( $term['term_id'] ); return (string) $term['term_id'];
} }
/** /**
@ -5566,7 +5566,7 @@ class wp_xmlrpc_server extends IXR_Server {
*/ */
do_action( 'xmlrpc_call_success_mw_newPost', $post_ID, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase do_action( 'xmlrpc_call_success_mw_newPost', $post_ID, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
return strval( $post_ID ); return (string) $post_ID;
} }
/** /**
@ -6555,7 +6555,7 @@ class wp_xmlrpc_server extends IXR_Server {
do_action( 'xmlrpc_call', 'mt.getPostCategories' ); do_action( 'xmlrpc_call', 'mt.getPostCategories' );
$categories = array(); $categories = array();
$catids = wp_get_post_categories( intval( $post_ID ) ); $catids = wp_get_post_categories( (int) $post_ID );
// First listed category will be the primary category. // First listed category will be the primary category.
$isPrimary = true; $isPrimary = true;
foreach ( $catids as $catid ) { foreach ( $catids as $catid ) {
@ -6812,7 +6812,7 @@ class wp_xmlrpc_server extends IXR_Server {
$post_ID = (int) $blah[1]; $post_ID = (int) $blah[1];
} elseif ( isset( $urltest['fragment'] ) ) { } elseif ( isset( $urltest['fragment'] ) ) {
// An #anchor is there, it's either... // An #anchor is there, it's either...
if ( intval( $urltest['fragment'] ) ) { if ( (int) $urltest['fragment'] ) {
// ...an integer #XXXX (simplest case), // ...an integer #XXXX (simplest case),
$post_ID = (int) $urltest['fragment']; $post_ID = (int) $urltest['fragment'];
} elseif ( preg_match( '/post-[0-9]+/', $urltest['fragment'] ) ) { } elseif ( preg_match( '/post-[0-9]+/', $urltest['fragment'] ) ) {

View File

@ -604,7 +604,7 @@ function get_comment_excerpt( $comment_ID = 0 ) {
} }
/* translators: Maximum number of words used in a comment excerpt. */ /* translators: Maximum number of words used in a comment excerpt. */
$comment_excerpt_length = intval( _x( '20', 'comment_excerpt_length' ) ); $comment_excerpt_length = (int) _x( '20', 'comment_excerpt_length' );
/** /**
* Filters the maximum number of words used in the comment excerpt. * Filters the maximum number of words used in the comment excerpt.
@ -2205,7 +2205,7 @@ function wp_list_comments( $args = array(), $comments = null ) {
} }
} }
// Validation check. // Validation check.
$parsed_args['page'] = intval( $parsed_args['page'] ); $parsed_args['page'] = (int) $parsed_args['page'];
if ( 0 == $parsed_args['page'] && 0 != $parsed_args['per_page'] ) { if ( 0 == $parsed_args['page'] && 0 != $parsed_args['per_page'] ) {
$parsed_args['page'] = 1; $parsed_args['page'] = 1;
} }

View File

@ -1254,7 +1254,7 @@ function wp_get_comment_fields_max_lengths() {
if ( ! is_array( $col_length ) && (int) $col_length > 0 ) { if ( ! is_array( $col_length ) && (int) $col_length > 0 ) {
$max_length = (int) $col_length; $max_length = (int) $col_length;
} elseif ( is_array( $col_length ) && isset( $col_length['length'] ) && intval( $col_length['length'] ) > 0 ) { } elseif ( is_array( $col_length ) && isset( $col_length['length'] ) && (int) $col_length['length'] > 0 ) {
$max_length = (int) $col_length['length']; $max_length = (int) $col_length['length'];
if ( ! empty( $col_length['type'] ) && 'byte' === $col_length['type'] ) { if ( ! empty( $col_length['type'] ) && 'byte' === $col_length['type'] ) {

View File

@ -81,8 +81,8 @@ class WP_Customize_Date_Time_Control extends WP_Customize_Control {
public function json() { public function json() {
$data = parent::json(); $data = parent::json();
$data['maxYear'] = intval( $this->max_year ); $data['maxYear'] = (int) $this->max_year;
$data['minYear'] = intval( $this->min_year ); $data['minYear'] = (int) $this->min_year;
$data['allowPastDate'] = (bool) $this->allow_past_date; $data['allowPastDate'] = (bool) $this->allow_past_date;
$data['twelveHourFormat'] = (bool) $this->twelve_hour_format; $data['twelveHourFormat'] = (bool) $this->twelve_hour_format;
$data['includeTime'] = (bool) $this->include_time; $data['includeTime'] = (bool) $this->include_time;
@ -245,7 +245,7 @@ class WP_Customize_Date_Time_Control extends WP_Customize_Control {
$timezone_info['description'] = ''; $timezone_info['description'] = '';
} }
} else { } else {
$formatted_gmt_offset = $this->format_gmt_offset( intval( get_option( 'gmt_offset', 0 ) ) ); $formatted_gmt_offset = $this->format_gmt_offset( (int) get_option( 'gmt_offset', 0 ) );
$timezone_info['description'] = sprintf( $timezone_info['description'] = sprintf(
/* translators: 1: UTC abbreviation and offset, 2: UTC offset. */ /* translators: 1: UTC abbreviation and offset, 2: UTC offset. */

View File

@ -171,7 +171,7 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
throw new Exception( "Illegal widget setting ID: $id" ); throw new Exception( "Illegal widget setting ID: $id" );
} }
$this->post_id = intval( $matches['id'] ); $this->post_id = (int) $matches['id'];
add_action( 'wp_update_nav_menu_item', array( $this, 'flush_cached_value' ), 10, 2 ); add_action( 'wp_update_nav_menu_item', array( $this, 'flush_cached_value' ), 10, 2 );
parent::__construct( $manager, $id, $args ); parent::__construct( $manager, $id, $args );
@ -368,7 +368,7 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
foreach ( array( 'object_id', 'menu_item_parent', 'nav_menu_term_id' ) as $key ) { foreach ( array( 'object_id', 'menu_item_parent', 'nav_menu_term_id' ) as $key ) {
if ( ! is_int( $this->value[ $key ] ) ) { if ( ! is_int( $this->value[ $key ] ) ) {
$this->value[ $key ] = intval( $this->value[ $key ] ); $this->value[ $key ] = (int) $this->value[ $key ];
} }
} }
foreach ( array( 'classes', 'xfn' ) as $key ) { foreach ( array( 'classes', 'xfn' ) as $key ) {
@ -684,11 +684,11 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
); );
$menu_item_value = array_merge( $default, $menu_item_value ); $menu_item_value = array_merge( $default, $menu_item_value );
$menu_item_value = wp_array_slice_assoc( $menu_item_value, array_keys( $default ) ); $menu_item_value = wp_array_slice_assoc( $menu_item_value, array_keys( $default ) );
$menu_item_value['position'] = intval( $menu_item_value['position'] ); $menu_item_value['position'] = (int) $menu_item_value['position'];
foreach ( array( 'object_id', 'menu_item_parent', 'nav_menu_term_id' ) as $key ) { foreach ( array( 'object_id', 'menu_item_parent', 'nav_menu_term_id' ) as $key ) {
// Note we need to allow negative-integer IDs for previewed objects not inserted yet. // Note we need to allow negative-integer IDs for previewed objects not inserted yet.
$menu_item_value[ $key ] = intval( $menu_item_value[ $key ] ); $menu_item_value[ $key ] = (int) $menu_item_value[ $key ];
} }
foreach ( array( 'type', 'object', 'target' ) as $key ) { foreach ( array( 'type', 'object', 'target' ) as $key ) {
@ -798,7 +798,7 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
return; return;
} }
if ( intval( $value['nav_menu_term_id'] ) !== $nav_menu_setting->previous_term_id ) { if ( (int) $value['nav_menu_term_id'] !== $nav_menu_setting->previous_term_id ) {
$this->update_status = 'error'; $this->update_status = 'error';
$this->update_error = new WP_Error( 'unexpected_previous_term_id' ); $this->update_error = new WP_Error( 'unexpected_previous_term_id' );
return; return;
@ -824,7 +824,7 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
return; return;
} }
if ( intval( $value['menu_item_parent'] ) !== $parent_nav_menu_item_setting->previous_post_id ) { if ( (int) $value['menu_item_parent'] !== $parent_nav_menu_item_setting->previous_post_id ) {
$this->update_status = 'error'; $this->update_status = 'error';
$this->update_error = new WP_Error( 'unexpected_previous_post_id' ); $this->update_error = new WP_Error( 'unexpected_previous_post_id' );
return; return;

View File

@ -34,7 +34,7 @@ class WP_Customize_Nav_Menu_Section extends WP_Customize_Section {
*/ */
public function json() { public function json() {
$exported = parent::json(); $exported = parent::json();
$exported['menu_id'] = intval( preg_replace( '/^nav_menu\[(-?\d+)\]/', '$1', $this->id ) ); $exported['menu_id'] = (int) preg_replace( '/^nav_menu\[(-?\d+)\]/', '$1', $this->id );
return $exported; return $exported;
} }

View File

@ -141,7 +141,7 @@ class WP_Customize_Nav_Menu_Setting extends WP_Customize_Setting {
throw new Exception( "Illegal widget setting ID: $id" ); throw new Exception( "Illegal widget setting ID: $id" );
} }
$this->term_id = intval( $matches['id'] ); $this->term_id = (int) $matches['id'];
parent::__construct( $manager, $id, $args ); parent::__construct( $manager, $id, $args );
} }
@ -433,7 +433,7 @@ class WP_Customize_Nav_Menu_Setting extends WP_Customize_Setting {
$value['name'] = trim( esc_html( $value['name'] ) ); // This sanitization code is used in wp-admin/nav-menus.php. $value['name'] = trim( esc_html( $value['name'] ) ); // This sanitization code is used in wp-admin/nav-menus.php.
$value['description'] = sanitize_text_field( $value['description'] ); $value['description'] = sanitize_text_field( $value['description'] );
$value['parent'] = max( 0, intval( $value['parent'] ) ); $value['parent'] = max( 0, (int) $value['parent'] );
$value['auto_add'] = ! empty( $value['auto_add'] ); $value['auto_add'] = ! empty( $value['auto_add'] );
if ( '' === $value['name'] ) { if ( '' === $value['name'] ) {
@ -556,7 +556,7 @@ class WP_Customize_Nav_Menu_Setting extends WP_Customize_Setting {
} }
$post_value = $setting->post_value( null ); $post_value = $setting->post_value( null );
if ( ! is_null( $post_value ) && intval( $post_value ) === $this->previous_term_id ) { if ( ! is_null( $post_value ) && (int) $post_value === $this->previous_term_id ) {
$this->manager->set_post_value( $setting->id, $this->term_id ); $this->manager->set_post_value( $setting->id, $this->term_id );
$setting->save(); $setting->save();
} }
@ -570,7 +570,7 @@ class WP_Customize_Nav_Menu_Setting extends WP_Customize_Setting {
} }
$widget_instance = $nav_menu_widget_setting->post_value(); // Note that this calls WP_Customize_Widgets::sanitize_widget_instance(). $widget_instance = $nav_menu_widget_setting->post_value(); // Note that this calls WP_Customize_Widgets::sanitize_widget_instance().
if ( empty( $widget_instance['nav_menu'] ) || intval( $widget_instance['nav_menu'] ) !== $this->previous_term_id ) { if ( empty( $widget_instance['nav_menu'] ) || (int) $widget_instance['nav_menu'] !== $this->previous_term_id ) {
continue; continue;
} }

View File

@ -3568,8 +3568,8 @@ function iso8601_timezone_to_offset( $timezone ) {
$offset = 0; $offset = 0;
} else { } else {
$sign = ( '+' === substr( $timezone, 0, 1 ) ) ? 1 : -1; $sign = ( '+' === substr( $timezone, 0, 1 ) ) ? 1 : -1;
$hours = intval( substr( $timezone, 1, 2 ) ); $hours = (int) substr( $timezone, 1, 2 );
$minutes = intval( substr( $timezone, 3, 4 ) ) / 60; $minutes = (int) substr( $timezone, 3, 4 ) / 60;
$offset = $sign * HOUR_IN_SECONDS * ( $hours + $minutes ); $offset = $sign * HOUR_IN_SECONDS * ( $hours + $minutes );
} }
return $offset; return $offset;
@ -3820,7 +3820,7 @@ function wp_trim_excerpt( $text = '', $post = null ) {
$text = str_replace( ']]>', ']]&gt;', $text ); $text = str_replace( ']]>', ']]&gt;', $text );
/* translators: Maximum number of words used in a post excerpt. */ /* translators: Maximum number of words used in a post excerpt. */
$excerpt_length = intval( _x( '55', 'excerpt_length' ) ); $excerpt_length = (int) _x( '55', 'excerpt_length' );
/** /**
* Filters the maximum number of words in a post excerpt. * Filters the maximum number of words in a post excerpt.
@ -4725,7 +4725,7 @@ function sanitize_option( $option, $value ) {
if ( null === $value ) { if ( null === $value ) {
$value = 1; $value = 1;
} else { } else {
$value = intval( $value ); $value = (int) $value;
} }
break; break;
@ -5067,7 +5067,7 @@ function wp_sprintf( $pattern, ...$args ) {
if ( $_fragment != $fragment ) { if ( $_fragment != $fragment ) {
$fragment = $_fragment; $fragment = $_fragment;
} else { } else {
$fragment = sprintf( $fragment, strval( $arg ) ); $fragment = sprintf( $fragment, (string) $arg );
} }
} }

View File

@ -4735,7 +4735,7 @@ function dead_db() {
* @return int A non-negative integer. * @return int A non-negative integer.
*/ */
function absint( $maybeint ) { function absint( $maybeint ) {
return abs( intval( $maybeint ) ); return abs( (int) $maybeint );
} }
/** /**

View File

@ -1339,7 +1339,7 @@ function wp_title( $sep = '&raquo;', $display = true, $seplocation = '' ) {
if ( is_archive() && ! empty( $m ) ) { if ( is_archive() && ! empty( $m ) ) {
$my_year = substr( $m, 0, 4 ); $my_year = substr( $m, 0, 4 );
$my_month = $wp_locale->get_month( substr( $m, 4, 2 ) ); $my_month = $wp_locale->get_month( substr( $m, 4, 2 ) );
$my_day = intval( substr( $m, 6, 2 ) ); $my_day = (int) substr( $m, 6, 2 );
$title = $my_year . ( $my_month ? $t_sep . $my_month : '' ) . ( $my_day ? $t_sep . $my_day : '' ); $title = $my_year . ( $my_month ? $t_sep . $my_month : '' ) . ( $my_day ? $t_sep . $my_day : '' );
} }
@ -2223,7 +2223,7 @@ function get_calendar( $initial = true, $echo = true ) {
// Let's figure out when we are. // Let's figure out when we are.
if ( ! empty( $monthnum ) && ! empty( $year ) ) { if ( ! empty( $monthnum ) && ! empty( $year ) ) {
$thismonth = zeroise( intval( $monthnum ), 2 ); $thismonth = zeroise( (int) $monthnum, 2 );
$thisyear = (int) $year; $thisyear = (int) $year;
} elseif ( ! empty( $w ) ) { } elseif ( ! empty( $w ) ) {
// We need to get the month from MySQL. // We need to get the month from MySQL.
@ -3149,7 +3149,7 @@ function feed_links_extra( $args = array() ) {
$href = get_term_feed_link( $term->term_id, $term->taxonomy ); $href = get_term_feed_link( $term->term_id, $term->taxonomy );
} }
} elseif ( is_author() ) { } elseif ( is_author() ) {
$author_id = intval( get_query_var( 'author' ) ); $author_id = (int) get_query_var( 'author' );
$title = sprintf( $args['authortitle'], get_bloginfo( 'name' ), $args['separator'], get_the_author_meta( 'display_name', $author_id ) ); $title = sprintf( $args['authortitle'], get_bloginfo( 'name' ), $args['separator'], get_the_author_meta( 'display_name', $author_id ) );
$href = get_author_feed_link( $author_id ); $href = get_author_feed_link( $author_id );
@ -3459,7 +3459,7 @@ function user_can_richedit() {
if ( 'true' === get_user_option( 'rich_editing' ) || ! is_user_logged_in() ) { // Default to 'true' for logged out users. if ( 'true' === get_user_option( 'rich_editing' ) || ! is_user_logged_in() ) { // Default to 'true' for logged out users.
if ( $is_safari ) { if ( $is_safari ) {
$wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 ); $wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && (int) $match[1] >= 534 );
} elseif ( $is_IE ) { } elseif ( $is_IE ) {
$wp_rich_edit = ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Trident/7.0;' ) !== false ); $wp_rich_edit = ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Trident/7.0;' ) !== false );
} elseif ( $is_gecko || $is_chrome || $is_edge || ( $is_opera && ! wp_is_mobile() ) ) { } elseif ( $is_gecko || $is_chrome || $is_edge || ( $is_opera && ! wp_is_mobile() ) ) {
@ -4195,7 +4195,7 @@ function paginate_links( $args = '' ) {
// Get max pages and current page out of the current query, if available. // Get max pages and current page out of the current query, if available.
$total = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1; $total = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1;
$current = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1; $current = get_query_var( 'paged' ) ? (int) get_query_var( 'paged' ) : 1;
// Append the format placeholder to the base URL. // Append the format placeholder to the base URL.
$pagenum_link = trailingslashit( $url_parts[0] ) . '%_%'; $pagenum_link = trailingslashit( $url_parts[0] ) . '%_%';

View File

@ -668,7 +668,7 @@ function ms_allowed_http_request_hosts( $is_external, $host ) {
*/ */
function wp_parse_url( $url, $component = -1 ) { function wp_parse_url( $url, $component = -1 ) {
$to_unset = array(); $to_unset = array();
$url = strval( $url ); $url = (string) $url;
if ( '//' === substr( $url, 0, 2 ) ) { if ( '//' === substr( $url, 0, 2 ) ) {
$to_unset[] = 'scheme'; $to_unset[] = 'scheme';

View File

@ -515,7 +515,7 @@ function get_month_link( $year, $month ) {
$monthlink = $wp_rewrite->get_month_permastruct(); $monthlink = $wp_rewrite->get_month_permastruct();
if ( ! empty( $monthlink ) ) { if ( ! empty( $monthlink ) ) {
$monthlink = str_replace( '%year%', $year, $monthlink ); $monthlink = str_replace( '%year%', $year, $monthlink );
$monthlink = str_replace( '%monthnum%', zeroise( intval( $month ), 2 ), $monthlink ); $monthlink = str_replace( '%monthnum%', zeroise( (int) $month, 2 ), $monthlink );
$monthlink = home_url( user_trailingslashit( $monthlink, 'month' ) ); $monthlink = home_url( user_trailingslashit( $monthlink, 'month' ) );
} else { } else {
$monthlink = home_url( '?m=' . $year . zeroise( $month, 2 ) ); $monthlink = home_url( '?m=' . $year . zeroise( $month, 2 ) );
@ -560,8 +560,8 @@ function get_day_link( $year, $month, $day ) {
$daylink = $wp_rewrite->get_day_permastruct(); $daylink = $wp_rewrite->get_day_permastruct();
if ( ! empty( $daylink ) ) { if ( ! empty( $daylink ) ) {
$daylink = str_replace( '%year%', $year, $daylink ); $daylink = str_replace( '%year%', $year, $daylink );
$daylink = str_replace( '%monthnum%', zeroise( intval( $month ), 2 ), $daylink ); $daylink = str_replace( '%monthnum%', zeroise( (int) $month, 2 ), $daylink );
$daylink = str_replace( '%day%', zeroise( intval( $day ), 2 ), $daylink ); $daylink = str_replace( '%day%', zeroise( (int) $day, 2 ), $daylink );
$daylink = home_url( user_trailingslashit( $daylink, 'day' ) ); $daylink = home_url( user_trailingslashit( $daylink, 'day' ) );
} else { } else {
$daylink = home_url( '?m=' . $year . zeroise( $month, 2 ) . zeroise( $day, 2 ) ); $daylink = home_url( '?m=' . $year . zeroise( $month, 2 ) . zeroise( $day, 2 ) );
@ -2320,7 +2320,7 @@ function get_next_posts_page_link( $max_page = 0 ) {
if ( ! $paged ) { if ( ! $paged ) {
$paged = 1; $paged = 1;
} }
$nextpage = intval( $paged ) + 1; $nextpage = (int) $paged + 1;
if ( ! $max_page || $max_page >= $nextpage ) { if ( ! $max_page || $max_page >= $nextpage ) {
return get_pagenum_link( $nextpage ); return get_pagenum_link( $nextpage );
} }
@ -2369,7 +2369,7 @@ function get_next_posts_link( $label = null, $max_page = 0 ) {
$paged = 1; $paged = 1;
} }
$nextpage = intval( $paged ) + 1; $nextpage = (int) $paged + 1;
if ( null === $label ) { if ( null === $label ) {
$label = __( 'Next Page &raquo;' ); $label = __( 'Next Page &raquo;' );
@ -2418,7 +2418,7 @@ function get_previous_posts_page_link() {
global $paged; global $paged;
if ( ! is_single() ) { if ( ! is_single() ) {
$nextpage = intval( $paged ) - 1; $nextpage = (int) $paged - 1;
if ( $nextpage < 1 ) { if ( $nextpage < 1 ) {
$nextpage = 1; $nextpage = 1;
} }
@ -2891,7 +2891,7 @@ function get_next_comments_link( $label = '', $max_page = 0 ) {
$page = 1; $page = 1;
} }
$nextpage = intval( $page ) + 1; $nextpage = (int) $page + 1;
if ( empty( $max_page ) ) { if ( empty( $max_page ) ) {
$max_page = $wp_query->max_num_comment_pages; $max_page = $wp_query->max_num_comment_pages;
@ -2946,11 +2946,11 @@ function get_previous_comments_link( $label = '' ) {
$page = get_query_var( 'cpage' ); $page = get_query_var( 'cpage' );
if ( intval( $page ) <= 1 ) { if ( (int) $page <= 1 ) {
return; return;
} }
$prevpage = intval( $page ) - 1; $prevpage = (int) $page - 1;
if ( empty( $label ) ) { if ( empty( $label ) ) {
$label = __( '&laquo; Older Comments' ); $label = __( '&laquo; Older Comments' );

View File

@ -70,23 +70,23 @@ function image_constrain_size_for_editor( $width, $height, $size = 'medium', $co
$max_width = $size[0]; $max_width = $size[0];
$max_height = $size[1]; $max_height = $size[1];
} elseif ( 'thumb' === $size || 'thumbnail' === $size ) { } elseif ( 'thumb' === $size || 'thumbnail' === $size ) {
$max_width = intval( get_option( 'thumbnail_size_w' ) ); $max_width = (int) get_option( 'thumbnail_size_w' );
$max_height = intval( get_option( 'thumbnail_size_h' ) ); $max_height = (int) get_option( 'thumbnail_size_h' );
// Last chance thumbnail size defaults. // Last chance thumbnail size defaults.
if ( ! $max_width && ! $max_height ) { if ( ! $max_width && ! $max_height ) {
$max_width = 128; $max_width = 128;
$max_height = 96; $max_height = 96;
} }
} elseif ( 'medium' === $size ) { } elseif ( 'medium' === $size ) {
$max_width = intval( get_option( 'medium_size_w' ) ); $max_width = (int) get_option( 'medium_size_w' );
$max_height = intval( get_option( 'medium_size_h' ) ); $max_height = (int) get_option( 'medium_size_h' );
} elseif ( 'medium_large' === $size ) { } elseif ( 'medium_large' === $size ) {
$max_width = intval( get_option( 'medium_large_size_w' ) ); $max_width = (int) get_option( 'medium_large_size_w' );
$max_height = intval( get_option( 'medium_large_size_h' ) ); $max_height = (int) get_option( 'medium_large_size_h' );
if ( intval( $content_width ) > 0 ) { if ( (int) $content_width > 0 ) {
$max_width = min( intval( $content_width ), $max_width ); $max_width = min( (int) $content_width, $max_width );
} }
} elseif ( 'large' === $size ) { } elseif ( 'large' === $size ) {
/* /*
@ -95,18 +95,18 @@ function image_constrain_size_for_editor( $width, $height, $size = 'medium', $co
* itself, and within the theme's content width if it's known. The user * itself, and within the theme's content width if it's known. The user
* can resize it in the editor if they wish. * can resize it in the editor if they wish.
*/ */
$max_width = intval( get_option( 'large_size_w' ) ); $max_width = (int) get_option( 'large_size_w' );
$max_height = intval( get_option( 'large_size_h' ) ); $max_height = (int) get_option( 'large_size_h' );
if ( intval( $content_width ) > 0 ) { if ( (int) $content_width > 0 ) {
$max_width = min( intval( $content_width ), $max_width ); $max_width = min( (int) $content_width, $max_width );
} }
} elseif ( ! empty( $_wp_additional_image_sizes ) && in_array( $size, array_keys( $_wp_additional_image_sizes ), true ) ) { } elseif ( ! empty( $_wp_additional_image_sizes ) && in_array( $size, array_keys( $_wp_additional_image_sizes ), true ) ) {
$max_width = intval( $_wp_additional_image_sizes[ $size ]['width'] ); $max_width = (int) $_wp_additional_image_sizes[ $size ]['width'];
$max_height = intval( $_wp_additional_image_sizes[ $size ]['height'] ); $max_height = (int) $_wp_additional_image_sizes[ $size ]['height'];
// Only in admin. Assume that theme authors know what they're doing. // Only in admin. Assume that theme authors know what they're doing.
if ( intval( $content_width ) > 0 && 'edit' === $context ) { if ( (int) $content_width > 0 && 'edit' === $context ) {
$max_width = min( intval( $content_width ), $max_width ); $max_width = min( (int) $content_width, $max_width );
} }
} else { // $size === 'full' has no constraint. } else { // $size === 'full' has no constraint.
$max_width = $width; $max_width = $width;
@ -155,10 +155,10 @@ function image_constrain_size_for_editor( $width, $height, $size = 'medium', $co
function image_hwstring( $width, $height ) { function image_hwstring( $width, $height ) {
$out = ''; $out = '';
if ( $width ) { if ( $width ) {
$out .= 'width="' . intval( $width ) . '" '; $out .= 'width="' . (int) $width . '" ';
} }
if ( $height ) { if ( $height ) {
$out .= 'height="' . intval( $height ) . '" '; $out .= 'height="' . (int) $height . '" ';
} }
return $out; return $out;
} }
@ -775,7 +775,7 @@ function image_get_intermediate_size( $post_id, $size = 'thumbnail' ) {
foreach ( $imagedata['sizes'] as $_size => $data ) { foreach ( $imagedata['sizes'] as $_size => $data ) {
// If there's an exact match to an existing image size, short circuit. // If there's an exact match to an existing image size, short circuit.
if ( intval( $data['width'] ) === intval( $size[0] ) && intval( $data['height'] ) === intval( $size[1] ) ) { if ( (int) $data['width'] === (int) $size[0] && (int) $data['height'] === (int) $size[1] ) {
$candidates[ $data['width'] * $data['height'] ] = $data; $candidates[ $data['width'] * $data['height'] ] = $data;
break; break;
} }
@ -896,16 +896,16 @@ function wp_get_registered_image_subsizes() {
if ( isset( $additional_sizes[ $size_name ]['width'] ) ) { if ( isset( $additional_sizes[ $size_name ]['width'] ) ) {
// For sizes added by plugins and themes. // For sizes added by plugins and themes.
$size_data['width'] = intval( $additional_sizes[ $size_name ]['width'] ); $size_data['width'] = (int) $additional_sizes[ $size_name ]['width'];
} else { } else {
// For default sizes set in options. // For default sizes set in options.
$size_data['width'] = intval( get_option( "{$size_name}_size_w" ) ); $size_data['width'] = (int) get_option( "{$size_name}_size_w" );
} }
if ( isset( $additional_sizes[ $size_name ]['height'] ) ) { if ( isset( $additional_sizes[ $size_name ]['height'] ) ) {
$size_data['height'] = intval( $additional_sizes[ $size_name ]['height'] ); $size_data['height'] = (int) $additional_sizes[ $size_name ]['height'];
} else { } else {
$size_data['height'] = intval( get_option( "{$size_name}_size_h" ) ); $size_data['height'] = (int) get_option( "{$size_name}_size_h" );
} }
if ( empty( $size_data['width'] ) && empty( $size_data['height'] ) ) { if ( empty( $size_data['width'] ) && empty( $size_data['height'] ) ) {
@ -2215,7 +2215,7 @@ function gallery_shortcode( $attr ) {
'gallery' 'gallery'
); );
$id = intval( $atts['id'] ); $id = (int) $atts['id'];
if ( ! empty( $atts['include'] ) ) { if ( ! empty( $atts['include'] ) ) {
$_attachments = get_posts( $_attachments = get_posts(
@ -2293,7 +2293,7 @@ function gallery_shortcode( $attr ) {
$icontag = 'dt'; $icontag = 'dt';
} }
$columns = intval( $atts['columns'] ); $columns = (int) $atts['columns'];
$itemwidth = $columns > 0 ? floor( 100 / $columns ) : 100; $itemwidth = $columns > 0 ? floor( 100 / $columns ) : 100;
$float = is_rtl() ? 'right' : 'left'; $float = is_rtl() ? 'right' : 'left';
@ -2553,7 +2553,7 @@ function wp_playlist_shortcode( $attr ) {
'playlist' 'playlist'
); );
$id = intval( $atts['id'] ); $id = (int) $atts['id'];
if ( 'audio' !== $atts['type'] ) { if ( 'audio' !== $atts['type'] ) {
$atts['type'] = 'video'; $atts['type'] = 'video';
@ -3330,7 +3330,7 @@ function adjacent_image_link( $prev = true, $size = 'thumbnail', $text = false )
); );
foreach ( $attachments as $k => $attachment ) { foreach ( $attachments as $k => $attachment ) {
if ( intval( $attachment->ID ) === intval( $post->ID ) ) { if ( (int) $attachment->ID === (int) $post->ID ) {
break; break;
} }
} }
@ -4516,7 +4516,7 @@ function get_post_galleries( $post, $html = true ) {
// Specify the post ID of the gallery we're viewing if the shortcode doesn't reference another post already. // Specify the post ID of the gallery we're viewing if the shortcode doesn't reference another post already.
if ( ! isset( $shortcode_attrs['id'] ) ) { if ( ! isset( $shortcode_attrs['id'] ) ) {
$shortcode[3] .= ' id="' . intval( $post->ID ) . '"'; $shortcode[3] .= ' id="' . (int) $post->ID . '"';
} }
$gallery = do_shortcode_tag( $shortcode ); $gallery = do_shortcode_tag( $shortcode );

View File

@ -722,7 +722,7 @@ function get_metadata_by_mid( $meta_type, $meta_id ) {
return false; return false;
} }
$meta_id = intval( $meta_id ); $meta_id = (int) $meta_id;
if ( $meta_id <= 0 ) { if ( $meta_id <= 0 ) {
return false; return false;
} }
@ -786,7 +786,7 @@ function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key =
return false; return false;
} }
$meta_id = intval( $meta_id ); $meta_id = (int) $meta_id;
if ( $meta_id <= 0 ) { if ( $meta_id <= 0 ) {
return false; return false;
} }
@ -901,7 +901,7 @@ function delete_metadata_by_mid( $meta_type, $meta_id ) {
return false; return false;
} }
$meta_id = intval( $meta_id ); $meta_id = (int) $meta_id;
if ( $meta_id <= 0 ) { if ( $meta_id <= 0 ) {
return false; return false;
} }
@ -1062,7 +1062,7 @@ function update_meta_cache( $meta_type, $object_ids ) {
if ( ! empty( $meta_list ) ) { if ( ! empty( $meta_list ) ) {
foreach ( $meta_list as $metarow ) { foreach ( $meta_list as $metarow ) {
$mpid = intval( $metarow[ $column ] ); $mpid = (int) $metarow[ $column ];
$mkey = $metarow['meta_key']; $mkey = $metarow['meta_key'];
$mval = $metarow['meta_value']; $mval = $metarow['meta_value'];

View File

@ -708,7 +708,7 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) {
$mydomain = $blogname . '.' . preg_replace( '|^www\.|', '', $domain ); $mydomain = $blogname . '.' . preg_replace( '|^www\.|', '', $domain );
$path = $base; $path = $base;
} else { } else {
$mydomain = "$domain"; $mydomain = $domain;
$path = $base . $blogname . '/'; $path = $base . $blogname . '/';
} }
if ( domain_exists( $mydomain, $path, $current_network->id ) ) { if ( domain_exists( $mydomain, $path, $current_network->id ) ) {
@ -1970,7 +1970,7 @@ function global_terms( $term_id, $deprecated = '' ) {
return $term_id; return $term_id;
} }
$term_id = intval( $term_id ); $term_id = (int) $term_id;
$c = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->terms WHERE term_id = %d", $term_id ) ); $c = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->terms WHERE term_id = %d", $term_id ) );
$global_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM $wpdb->sitecategories WHERE category_nicename = %s", $c->slug ) ); $global_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM $wpdb->sitecategories WHERE category_nicename = %s", $c->slug ) );

View File

@ -552,8 +552,8 @@ function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item
$menu_item_db_id = (int) $menu_item_db_id; $menu_item_db_id = (int) $menu_item_db_id;
update_post_meta( $menu_item_db_id, '_menu_item_type', sanitize_key( $args['menu-item-type'] ) ); update_post_meta( $menu_item_db_id, '_menu_item_type', sanitize_key( $args['menu-item-type'] ) );
update_post_meta( $menu_item_db_id, '_menu_item_menu_item_parent', strval( (int) $args['menu-item-parent-id'] ) ); update_post_meta( $menu_item_db_id, '_menu_item_menu_item_parent', (string) ( (int) $args['menu-item-parent-id'] ) );
update_post_meta( $menu_item_db_id, '_menu_item_object_id', strval( (int) $args['menu-item-object-id'] ) ); update_post_meta( $menu_item_db_id, '_menu_item_object_id', (string) ( (int) $args['menu-item-object-id'] ) );
update_post_meta( $menu_item_db_id, '_menu_item_object', sanitize_key( $args['menu-item-object'] ) ); update_post_meta( $menu_item_db_id, '_menu_item_object', sanitize_key( $args['menu-item-object'] ) );
update_post_meta( $menu_item_db_id, '_menu_item_target', sanitize_key( $args['menu-item-target'] ) ); update_post_meta( $menu_item_db_id, '_menu_item_target', sanitize_key( $args['menu-item-target'] ) );

View File

@ -2540,7 +2540,7 @@ if ( ! function_exists( 'wp_rand' ) ) :
$value = $min + ( $max - $min + 1 ) * $value / ( $max_random_number + 1 ); $value = $min + ( $max - $min + 1 ) * $value / ( $max_random_number + 1 );
} }
return abs( intval( $value ) ); return abs( (int) $value );
} }
endif; endif;

View File

@ -4135,7 +4135,7 @@ function wp_insert_post( $postarr, $wp_error = false ) {
} }
if ( $thumbnail_support ) { if ( $thumbnail_support ) {
$thumbnail_id = intval( $postarr['_thumbnail_id'] ); $thumbnail_id = (int) $postarr['_thumbnail_id'];
if ( -1 === $thumbnail_id ) { if ( -1 === $thumbnail_id ) {
delete_post_thumbnail( $post_ID ); delete_post_thumbnail( $post_ID );
} else { } else {
@ -4593,7 +4593,7 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p
// Prevent new post slugs that could result in URLs that conflict with date archives. // Prevent new post slugs that could result in URLs that conflict with date archives.
$conflicts_with_date_archive = false; $conflicts_with_date_archive = false;
if ( 'post' === $post_type && ( ! $post || $post->post_name !== $slug ) && preg_match( '/^[0-9]+$/', $slug ) ) { if ( 'post' === $post_type && ( ! $post || $post->post_name !== $slug ) && preg_match( '/^[0-9]+$/', $slug ) ) {
$slug_num = intval( $slug ); $slug_num = (int) $slug;
if ( $slug_num ) { if ( $slug_num ) {
$permastructs = array_values( array_filter( explode( '/', get_option( 'permalink_structure' ) ) ) ); $permastructs = array_values( array_filter( explode( '/', get_option( 'permalink_structure' ) ) ) );
@ -5266,7 +5266,7 @@ function get_page_children( $page_id, $pages ) {
// Build a hash of ID -> children. // Build a hash of ID -> children.
$children = array(); $children = array();
foreach ( (array) $pages as $page ) { foreach ( (array) $pages as $page ) {
$children[ intval( $page->post_parent ) ][] = $page; $children[ (int) $page->post_parent ][] = $page;
} }
$page_list = array(); $page_list = array();
@ -5310,7 +5310,7 @@ function get_page_hierarchy( &$pages, $page_id = 0 ) {
$children = array(); $children = array();
foreach ( (array) $pages as $p ) { foreach ( (array) $pages as $p ) {
$parent_id = intval( $p->post_parent ); $parent_id = (int) $p->post_parent;
$children[ $parent_id ][] = $p; $children[ $parent_id ][] = $p;
} }
@ -5519,7 +5519,7 @@ function get_pages( $args = array() ) {
if ( ! empty( $post_authors ) ) { if ( ! empty( $post_authors ) ) {
foreach ( $post_authors as $post_author ) { foreach ( $post_authors as $post_author ) {
// Do we have an author id or an author login? // Do we have an author id or an author login?
if ( 0 == intval( $post_author ) ) { if ( 0 == (int) $post_author ) {
$post_author = get_user_by( 'login', $post_author ); $post_author = get_user_by( 'login', $post_author );
if ( empty( $post_author ) ) { if ( empty( $post_author ) ) {
continue; continue;

View File

@ -1320,7 +1320,7 @@ function rest_is_boolean( $maybe_bool ) {
* @return bool True if an integer, otherwise false. * @return bool True if an integer, otherwise false.
*/ */
function rest_is_integer( $maybe_integer ) { function rest_is_integer( $maybe_integer ) {
return is_numeric( $maybe_integer ) && round( floatval( $maybe_integer ) ) === floatval( $maybe_integer ); return is_numeric( $maybe_integer ) && round( (float) $maybe_integer ) === (float) $maybe_integer;
} }
/** /**
@ -2012,7 +2012,7 @@ function rest_sanitize_value_from_schema( $value, $args, $param = '' ) {
} }
if ( 'string' === $args['type'] ) { if ( 'string' === $args['type'] ) {
return strval( $value ); return (string) $value;
} }
return $value; return $value;

View File

@ -499,10 +499,10 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller {
if ( $crop ) { if ( $crop ) {
$size = $image_editor->get_size(); $size = $image_editor->get_size();
$crop_x = round( ( $size['width'] * floatval( $request['x'] ) ) / 100.0 ); $crop_x = round( ( $size['width'] * (float) $request['x'] ) / 100.0 );
$crop_y = round( ( $size['height'] * floatval( $request['y'] ) ) / 100.0 ); $crop_y = round( ( $size['height'] * (float) $request['y'] ) / 100.0 );
$width = round( ( $size['width'] * floatval( $request['width'] ) ) / 100.0 ); $width = round( ( $size['width'] * (float) $request['width'] ) / 100.0 );
$height = round( ( $size['height'] * floatval( $request['height'] ) ) / 100.0 ); $height = round( ( $size['height'] * (float) $request['height'] ) / 100.0 );
$result = $image_editor->crop( $crop_x, $crop_y, $width, $height ); $result = $image_editor->crop( $crop_x, $crop_y, $width, $height );

View File

@ -128,10 +128,10 @@ class WP_REST_Block_Directory_Controller extends WP_REST_Controller {
'description' => wp_trim_words( $plugin['description'], 30, '...' ), 'description' => wp_trim_words( $plugin['description'], 30, '...' ),
'id' => $plugin['slug'], 'id' => $plugin['slug'],
'rating' => $plugin['rating'] / 20, 'rating' => $plugin['rating'] / 20,
'rating_count' => intval( $plugin['num_ratings'] ), 'rating_count' => (int) $plugin['num_ratings'],
'active_installs' => intval( $plugin['active_installs'] ), 'active_installs' => (int) $plugin['active_installs'],
'author_block_rating' => $plugin['author_block_rating'] / 20, 'author_block_rating' => $plugin['author_block_rating'] / 20,
'author_block_count' => intval( $plugin['author_block_count'] ), 'author_block_count' => (int) $plugin['author_block_count'],
'author' => wp_strip_all_tags( $plugin['author'] ), 'author' => wp_strip_all_tags( $plugin['author'] ),
'icon' => ( isset( $plugin['icons']['1x'] ) ? $plugin['icons']['1x'] : 'block-default' ), 'icon' => ( isset( $plugin['icons']['1x'] ) ? $plugin['icons']['1x'] : 'block-default' ),
'last_updated' => gmdate( 'Y-m-d\TH:i:s', strtotime( $plugin['last_updated'] ) ), 'last_updated' => gmdate( 'Y-m-d\TH:i:s', strtotime( $plugin['last_updated'] ) ),

View File

@ -109,7 +109,7 @@ class WP_REST_Block_Renderer_Controller extends WP_REST_Controller {
public function get_item_permissions_check( $request ) { public function get_item_permissions_check( $request ) {
global $post; global $post;
$post_id = isset( $request['post_id'] ) ? intval( $request['post_id'] ) : 0; $post_id = isset( $request['post_id'] ) ? (int) $request['post_id'] : 0;
if ( 0 < $post_id ) { if ( 0 < $post_id ) {
$post = get_post( $post_id ); $post = get_post( $post_id );
@ -149,7 +149,7 @@ class WP_REST_Block_Renderer_Controller extends WP_REST_Controller {
public function get_item( $request ) { public function get_item( $request ) {
global $post; global $post;
$post_id = isset( $request['post_id'] ) ? intval( $request['post_id'] ) : 0; $post_id = isset( $request['post_id'] ) ? (int) $request['post_id'] : 0;
if ( 0 < $post_id ) { if ( 0 < $post_id ) {
$post = get_post( $post_id ); $post = get_post( $post_id );

View File

@ -547,7 +547,7 @@ function wp_revisions_to_keep( $post ) {
if ( true === $num ) { if ( true === $num ) {
$num = -1; $num = -1;
} else { } else {
$num = intval( $num ); $num = (int) $num;
} }
if ( ! post_type_supports( $post->post_type, 'revisions' ) ) { if ( ! post_type_supports( $post->post_type, 'revisions' ) ) {
@ -678,12 +678,12 @@ function _wp_preview_post_thumbnail_filter( $value, $post_id, $meta_key ) {
return $value; return $value;
} }
$thumbnail_id = intval( $_REQUEST['_thumbnail_id'] ); $thumbnail_id = (int) $_REQUEST['_thumbnail_id'];
if ( $thumbnail_id <= 0 ) { if ( $thumbnail_id <= 0 ) {
return ''; return '';
} }
return strval( $thumbnail_id ); return (string) $thumbnail_id;
} }
/** /**

View File

@ -400,12 +400,12 @@ function wp_resolve_numeric_slug_conflicts( $query_vars = array() ) {
// If the date of the post doesn't match the date specified in the URL, resolve to the date archive. // If the date of the post doesn't match the date specified in the URL, resolve to the date archive.
if ( preg_match( '/^([0-9]{4})\-([0-9]{2})/', $post->post_date, $matches ) && isset( $query_vars['year'] ) && ( 'monthnum' === $compare || 'day' === $compare ) ) { if ( preg_match( '/^([0-9]{4})\-([0-9]{2})/', $post->post_date, $matches ) && isset( $query_vars['year'] ) && ( 'monthnum' === $compare || 'day' === $compare ) ) {
// $matches[1] is the year the post was published. // $matches[1] is the year the post was published.
if ( intval( $query_vars['year'] ) !== intval( $matches[1] ) ) { if ( (int) $query_vars['year'] !== (int) $matches[1] ) {
return $query_vars; return $query_vars;
} }
// $matches[2] is the month the post was published. // $matches[2] is the month the post was published.
if ( 'day' === $compare && isset( $query_vars['monthnum'] ) && intval( $query_vars['monthnum'] ) !== intval( $matches[2] ) ) { if ( 'day' === $compare && isset( $query_vars['monthnum'] ) && (int) $query_vars['monthnum'] !== (int) $matches[2] ) {
return $query_vars; return $query_vars;
} }
} }
@ -437,7 +437,7 @@ function wp_resolve_numeric_slug_conflicts( $query_vars = array() ) {
// If we've gotten to this point, we have a slug/date clash. First, adjust for nextpage. // If we've gotten to this point, we have a slug/date clash. First, adjust for nextpage.
if ( '' !== $maybe_page ) { if ( '' !== $maybe_page ) {
$query_vars['page'] = intval( $maybe_page ); $query_vars['page'] = (int) $maybe_page;
} }
// Next, unset autodetected date-related query vars. // Next, unset autodetected date-related query vars.

View File

@ -1048,7 +1048,7 @@ function get_term_children( $term_id, $taxonomy ) {
return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
} }
$term_id = intval( $term_id ); $term_id = (int) $term_id;
$terms = _get_term_hierarchy( $taxonomy ); $terms = _get_term_hierarchy( $taxonomy );
@ -3490,9 +3490,9 @@ function get_object_term_cache( $id, $taxonomy ) {
$term_ids = array(); $term_ids = array();
foreach ( $_term_ids as $term_id ) { foreach ( $_term_ids as $term_id ) {
if ( is_numeric( $term_id ) ) { if ( is_numeric( $term_id ) ) {
$term_ids[] = intval( $term_id ); $term_ids[] = (int) $term_id;
} elseif ( isset( $term_id->term_id ) ) { } elseif ( isset( $term_id->term_id ) ) {
$term_ids[] = intval( $term_id->term_id ); $term_ids[] = (int) $term_id->term_id;
} }
} }
@ -3948,12 +3948,12 @@ function _split_shared_term( $term_id, $term_taxonomy_id, $record = true ) {
if ( is_object( $term_id ) ) { if ( is_object( $term_id ) ) {
$shared_term = $term_id; $shared_term = $term_id;
$term_id = intval( $shared_term->term_id ); $term_id = (int) $shared_term->term_id;
} }
if ( is_object( $term_taxonomy_id ) ) { if ( is_object( $term_taxonomy_id ) ) {
$term_taxonomy = $term_taxonomy_id; $term_taxonomy = $term_taxonomy_id;
$term_taxonomy_id = intval( $term_taxonomy->term_taxonomy_id ); $term_taxonomy_id = (int) $term_taxonomy->term_taxonomy_id;
} }
// If there are no shared term_taxonomy rows, there's nothing to do here. // If there are no shared term_taxonomy rows, there's nothing to do here.
@ -4120,7 +4120,7 @@ function _wp_batch_split_terms() {
// Rekey shared term array for faster lookups. // Rekey shared term array for faster lookups.
$_shared_terms = array(); $_shared_terms = array();
foreach ( $shared_terms as $shared_term ) { foreach ( $shared_terms as $shared_term ) {
$term_id = intval( $shared_term->term_id ); $term_id = (int) $shared_term->term_id;
$_shared_terms[ $term_id ] = $shared_term; $_shared_terms[ $term_id ] = $shared_term;
} }
$shared_terms = $_shared_terms; $shared_terms = $_shared_terms;
@ -4134,7 +4134,7 @@ function _wp_batch_split_terms() {
$skipped_first_term = array(); $skipped_first_term = array();
$taxonomies = array(); $taxonomies = array();
foreach ( $shared_tts as $shared_tt ) { foreach ( $shared_tts as $shared_tt ) {
$term_id = intval( $shared_tt->term_id ); $term_id = (int) $shared_tt->term_id;
// Don't split the first tt belonging to a given term_id. // Don't split the first tt belonging to a given term_id.
if ( ! isset( $skipped_first_term[ $term_id ] ) ) { if ( ! isset( $skipped_first_term[ $term_id ] ) ) {

View File

@ -322,7 +322,7 @@ function wp_update_plugins( $extra_stats = array() ) {
foreach ( $plugins as $file => $p ) { foreach ( $plugins as $file => $p ) {
$new_option->checked[ $file ] = $p['Version']; $new_option->checked[ $file ] = $p['Version'];
if ( ! isset( $current->checked[ $file ] ) || strval( $current->checked[ $file ] ) !== strval( $p['Version'] ) ) { if ( ! isset( $current->checked[ $file ] ) || (string) $current->checked[ $file ] !== (string) $p['Version'] ) {
$plugin_changed = true; $plugin_changed = true;
} }
} }
@ -527,7 +527,7 @@ function wp_update_themes( $extra_stats = array() ) {
$theme_changed = false; $theme_changed = false;
foreach ( $checked as $slug => $v ) { foreach ( $checked as $slug => $v ) {
if ( ! isset( $last_update->checked[ $slug ] ) || strval( $last_update->checked[ $slug ] ) !== strval( $v ) ) { if ( ! isset( $last_update->checked[ $slug ] ) || (string) $last_update->checked[ $slug ] !== (string) $v ) {
$theme_changed = true; $theme_changed = true;
} }
} }

View File

@ -134,7 +134,7 @@ $is_IIS = ! $is_apache && ( strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS'
* *
* @global bool $is_iis7 * @global bool $is_iis7
*/ */
$is_iis7 = $is_IIS && intval( substr( $_SERVER['SERVER_SOFTWARE'], strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/' ) + 14 ) ) >= 7; $is_iis7 = $is_IIS && (int) substr( $_SERVER['SERVER_SOFTWARE'], strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/' ) + 14 ) >= 7;
/** /**
* Test if the current browser runs on a mobile device (smart phone, tablet, etc.) * Test if the current browser runs on a mobile device (smart phone, tablet, etc.)

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.6-alpha-49107'; $wp_version = '5.6-alpha-49108';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -109,8 +109,8 @@ class WP_Widget_Links extends WP_Widget {
$instance['orderby'] = $new_instance['orderby']; $instance['orderby'] = $new_instance['orderby'];
} }
$instance['category'] = intval( $new_instance['category'] ); $instance['category'] = (int) $new_instance['category'];
$instance['limit'] = ! empty( $new_instance['limit'] ) ? intval( $new_instance['limit'] ) : -1; $instance['limit'] = ! empty( $new_instance['limit'] ) ? (int) $new_instance['limit'] : -1;
return $instance; return $instance;
} }
@ -138,7 +138,7 @@ class WP_Widget_Links extends WP_Widget {
) )
); );
$link_cats = get_terms( array( 'taxonomy' => 'link_category' ) ); $link_cats = get_terms( array( 'taxonomy' => 'link_category' ) );
$limit = intval( $instance['limit'] ); $limit = (int) $instance['limit'];
if ( ! $limit ) { if ( ! $limit ) {
$limit = -1; $limit = -1;
} }
@ -148,7 +148,7 @@ class WP_Widget_Links extends WP_Widget {
<select class="widefat" id="<?php echo $this->get_field_id( 'category' ); ?>" name="<?php echo $this->get_field_name( 'category' ); ?>"> <select class="widefat" id="<?php echo $this->get_field_id( 'category' ); ?>" name="<?php echo $this->get_field_name( 'category' ); ?>">
<option value=""><?php _ex( 'All Links', 'links widget' ); ?></option> <option value=""><?php _ex( 'All Links', 'links widget' ); ?></option>
<?php foreach ( $link_cats as $link_cat ) : ?> <?php foreach ( $link_cats as $link_cat ) : ?>
<option value="<?php echo intval( $link_cat->term_id ); ?>" <?php selected( $instance['category'], $link_cat->term_id ); ?>> <option value="<?php echo (int) $link_cat->term_id; ?>" <?php selected( $instance['category'], $link_cat->term_id ); ?>>
<?php echo esc_html( $link_cat->name ); ?> <?php echo esc_html( $link_cat->name ); ?>
</option> </option>
<?php endforeach; ?> <?php endforeach; ?>
@ -181,7 +181,7 @@ class WP_Widget_Links extends WP_Widget {
<p> <p>
<label for="<?php echo $this->get_field_id( 'limit' ); ?>"><?php _e( 'Number of links to show:' ); ?></label> <label for="<?php echo $this->get_field_id( 'limit' ); ?>"><?php _e( 'Number of links to show:' ); ?></label>
<input id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" type="text" value="<?php echo ( -1 !== $limit ) ? intval( $limit ) : ''; ?>" size="3" /> <input id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" type="text" value="<?php echo ( -1 !== $limit ) ? (int) $limit : ''; ?>" size="3" />
</p> </p>
<?php <?php
} }

View File

@ -343,7 +343,7 @@ abstract class WP_Widget_Media extends WP_Widget {
class="media-widget-instance-property" class="media-widget-instance-property"
name="<?php echo esc_attr( $this->get_field_name( $name ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $name ) ); ?>"
id="<?php echo esc_attr( $this->get_field_id( $name ) ); // Needed specifically by wpWidgets.appendTitle(). ?>" id="<?php echo esc_attr( $this->get_field_id( $name ) ); // Needed specifically by wpWidgets.appendTitle(). ?>"
value="<?php echo esc_attr( is_array( $value ) ? join( ',', $value ) : strval( $value ) ); ?>" value="<?php echo esc_attr( is_array( $value ) ? join( ',', $value ) : (string) $value ); ?>"
/> />
<?php <?php
endforeach; endforeach;

View File

@ -46,7 +46,7 @@ $request_array = 'HTTP_POST_VARS';
if ( ! isset( $_GET['tb_id'] ) || ! $_GET['tb_id'] ) { if ( ! isset( $_GET['tb_id'] ) || ! $_GET['tb_id'] ) {
$tb_id = explode( '/', $_SERVER['REQUEST_URI'] ); $tb_id = explode( '/', $_SERVER['REQUEST_URI'] );
$tb_id = intval( $tb_id[ count( $tb_id ) - 1 ] ); $tb_id = (int) $tb_id[ count( $tb_id ) - 1 ];
} }
$tb_url = isset( $_POST['url'] ) ? $_POST['url'] : ''; $tb_url = isset( $_POST['url'] ) ? $_POST['url'] : '';
@ -84,7 +84,7 @@ if ( is_single() || is_page() ) {
$tb_id = $posts[0]->ID; $tb_id = $posts[0]->ID;
} }
if ( ! isset( $tb_id ) || ! intval( $tb_id ) ) { if ( ! isset( $tb_id ) || ! (int) $tb_id ) {
trackback_response( 1, __( 'I really need an ID for this to work.' ) ); trackback_response( 1, __( 'I really need an ID for this to work.' ) );
} }