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. git-svn-id: https://develop.svn.wordpress.org/trunk@49108 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
eeae797340
commit
79703088c4
@ -170,7 +170,7 @@ if ( $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 .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
|
||||
$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );
|
||||
|
@ -39,8 +39,8 @@ if ( ! current_user_can( 'upload_files' ) ) {
|
||||
}
|
||||
|
||||
// Just fetch the detail form for that attachment.
|
||||
if ( isset( $_REQUEST['attachment_id'] ) && intval( $_REQUEST['attachment_id'] ) && $_REQUEST['fetch'] ) {
|
||||
$id = intval( $_REQUEST['attachment_id'] );
|
||||
if ( isset( $_REQUEST['attachment_id'] ) && (int) $_REQUEST['attachment_id'] && $_REQUEST['fetch'] ) {
|
||||
$id = (int) $_REQUEST['attachment_id'];
|
||||
$post = get_post( $id );
|
||||
if ( 'attachment' !== $post->post_type ) {
|
||||
wp_die( __( 'Invalid post type.' ) );
|
||||
|
@ -329,7 +329,7 @@ if ( isset( $_REQUEST['approved'] ) || isset( $_REQUEST['deleted'] ) || isset( $
|
||||
<?php $wp_list_table->search_box( __( 'Search Comments' ), 'comment' ); ?>
|
||||
|
||||
<?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; ?>
|
||||
<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 ) ); ?>" />
|
||||
|
@ -227,7 +227,7 @@ function wp_ajax_wp_compression_test() {
|
||||
* @since 3.1.0
|
||||
*/
|
||||
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 ) ) {
|
||||
wp_die( -1 );
|
||||
}
|
||||
@ -1954,7 +1954,7 @@ function wp_ajax_menu_quick_search() {
|
||||
*/
|
||||
function wp_ajax_get_permalink() {
|
||||
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 ) );
|
||||
}
|
||||
|
||||
@ -1965,7 +1965,7 @@ function wp_ajax_get_permalink() {
|
||||
*/
|
||||
function wp_ajax_sample_permalink() {
|
||||
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'] : '';
|
||||
$slug = isset( $_POST['new_slug'] ) ? $_POST['new_slug'] : null;
|
||||
wp_die( get_sample_permalink_html( $post_id, $title, $slug ) );
|
||||
@ -2594,7 +2594,7 @@ function wp_ajax_upload_attachment() {
|
||||
* @since 3.1.0
|
||||
*/
|
||||
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 ) ) {
|
||||
wp_die( -1 );
|
||||
@ -2651,12 +2651,12 @@ function wp_ajax_image_editor() {
|
||||
function wp_ajax_set_post_thumbnail() {
|
||||
$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 ) ) {
|
||||
wp_die( -1 );
|
||||
}
|
||||
|
||||
$thumbnail_id = intval( $_POST['thumbnail_id'] );
|
||||
$thumbnail_id = (int) $_POST['thumbnail_id'];
|
||||
|
||||
if ( $json ) {
|
||||
check_ajax_referer( "update-post_$post_ID" );
|
||||
@ -2687,7 +2687,7 @@ function wp_ajax_set_post_thumbnail() {
|
||||
* @since 4.6.0
|
||||
*/
|
||||
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" );
|
||||
|
||||
@ -2695,7 +2695,7 @@ function wp_ajax_get_post_thumbnail_html() {
|
||||
wp_die( -1 );
|
||||
}
|
||||
|
||||
$thumbnail_id = intval( $_POST['thumbnail_id'] );
|
||||
$thumbnail_id = (int) $_POST['thumbnail_id'];
|
||||
|
||||
// For backward compatibility, -1 refers to no featured image.
|
||||
if ( -1 === $thumbnail_id ) {
|
||||
@ -3208,7 +3208,7 @@ function wp_ajax_send_attachment_to_editor() {
|
||||
|
||||
$attachment = wp_unslash( $_POST['attachment'] );
|
||||
|
||||
$id = intval( $attachment['id'] );
|
||||
$id = (int) $attachment['id'];
|
||||
|
||||
$post = get_post( $id );
|
||||
if ( ! $post ) {
|
||||
@ -3221,7 +3221,7 @@ function wp_ajax_send_attachment_to_editor() {
|
||||
|
||||
if ( current_user_can( 'edit_post', $id ) ) {
|
||||
// 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 ) {
|
||||
wp_update_post(
|
||||
@ -3622,7 +3622,7 @@ function wp_ajax_parse_embed() {
|
||||
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 ) {
|
||||
$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.
|
||||
if ( isset( $_POST['maxwidth'] ) && is_numeric( $_POST['maxwidth'] ) && $_POST['maxwidth'] > 0 ) {
|
||||
if ( ! isset( $content_width ) ) {
|
||||
$content_width = intval( $_POST['maxwidth'] );
|
||||
$content_width = (int) $_POST['maxwidth'];
|
||||
} else {
|
||||
$content_width = min( $content_width, intval( $_POST['maxwidth'] ) );
|
||||
$content_width = min( $content_width, (int) $_POST['maxwidth'] );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 ) {
|
||||
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_db_id = ( ! empty( $item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0;
|
||||
|
||||
|
@ -37,7 +37,7 @@ class WP_Importer {
|
||||
if ( ! empty( $results ) ) {
|
||||
foreach ( $results as $r ) {
|
||||
// Set permalinks into array.
|
||||
$hashtable[ $r->meta_value ] = intval( $r->post_id );
|
||||
$hashtable[ $r->meta_value ] = (int) $r->post_id;
|
||||
}
|
||||
}
|
||||
} while ( count( $results ) == $limit );
|
||||
@ -69,7 +69,7 @@ class WP_Importer {
|
||||
$result = $wpdb->get_results( $sql );
|
||||
|
||||
if ( ! empty( $result ) ) {
|
||||
$count = intval( $result[0]->cnt );
|
||||
$count = (int) $result[0]->cnt;
|
||||
}
|
||||
|
||||
// Unset to save memory.
|
||||
@ -106,11 +106,11 @@ class WP_Importer {
|
||||
foreach ( $results as $r ) {
|
||||
// Explode comment_agent key.
|
||||
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.
|
||||
if ( $bid == $ca_bid ) {
|
||||
$hashtable[ $source_comment_id ] = intval( $r->comment_ID );
|
||||
$hashtable[ $source_comment_id ] = (int) $r->comment_ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -103,8 +103,8 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'number' => intval( $per_page ),
|
||||
'offset' => intval( ( $pagenum - 1 ) * $per_page ),
|
||||
'number' => (int) $per_page,
|
||||
'offset' => (int) ( ( $pagenum - 1 ) * $per_page ),
|
||||
'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'] ) ) : '';
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
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' ) &&
|
||||
|
@ -89,19 +89,17 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
'show_in_admin_all_list' => false,
|
||||
)
|
||||
);
|
||||
$this->user_posts_count = intval(
|
||||
$wpdb->get_var(
|
||||
$wpdb->prepare(
|
||||
"
|
||||
$this->user_posts_count = (int) $wpdb->get_var(
|
||||
$wpdb->prepare(
|
||||
"
|
||||
SELECT COUNT( 1 )
|
||||
FROM $wpdb->posts
|
||||
WHERE post_type = %s
|
||||
AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' )
|
||||
AND post_author = %d
|
||||
",
|
||||
$post_type,
|
||||
get_current_user_id()
|
||||
)
|
||||
$post_type,
|
||||
get_current_user_id()
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -54,7 +54,7 @@ class WP_Users_List_Table extends WP_List_Table {
|
||||
$this->is_site_users = 'site-users-network' === $this->screen->id;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -606,7 +606,7 @@ function wp_dashboard_recent_drafts( $drafts = false ) {
|
||||
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. */
|
||||
$draft_length = intval( _x( '10', 'draft_length' ) );
|
||||
$draft_length = (int) _x( '10', 'draft_length' );
|
||||
|
||||
$drafts = array_slice( $drafts, 0, 3 );
|
||||
foreach ( $drafts as $draft ) {
|
||||
@ -928,7 +928,7 @@ function wp_dashboard_recent_posts( $args ) {
|
||||
'post_status' => $args['status'],
|
||||
'orderby' => 'date',
|
||||
'order' => $args['order'],
|
||||
'posts_per_page' => intval( $args['max'] ),
|
||||
'posts_per_page' => (int) $args['max'],
|
||||
'no_found_rows' => true,
|
||||
'cache_results' => false,
|
||||
'perm' => ( 'future' === $args['status'] ) ? 'editable' : 'readable',
|
||||
|
@ -372,7 +372,7 @@ function export_wp( $args = array() ) {
|
||||
|
||||
foreach ( $authors as $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_email>' . wxr_cdata( $author->user_email ) . '</wp:author_email>';
|
||||
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 ) {
|
||||
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_slug>' . wxr_cdata( $menu->slug ) . '</wp:term_slug>';
|
||||
wxr_term_name( $menu );
|
||||
@ -478,7 +478,7 @@ function export_wp( $args = array() ) {
|
||||
|
||||
<?php foreach ( $cats as $c ) : ?>
|
||||
<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_parent><?php echo wxr_cdata( $c->parent ? $cats[ $c->parent ]->slug : '' ); ?></wp:category_parent>
|
||||
<?php
|
||||
@ -490,7 +490,7 @@ function export_wp( $args = array() ) {
|
||||
<?php endforeach; ?>
|
||||
<?php foreach ( $tags as $t ) : ?>
|
||||
<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>
|
||||
<?php
|
||||
wxr_tag_name( $t );
|
||||
@ -501,7 +501,7 @@ function export_wp( $args = array() ) {
|
||||
<?php endforeach; ?>
|
||||
<?php foreach ( $terms as $t ) : ?>
|
||||
<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_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>
|
||||
@ -573,18 +573,18 @@ function export_wp( $args = array() ) {
|
||||
<description></description>
|
||||
<content:encoded><?php echo $content; ?></content: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_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: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:status><?php echo wxr_cdata( $post->post_status ); ?></wp:status>
|
||||
<wp:post_parent><?php echo intval( $post->post_parent ); ?></wp:post_parent>
|
||||
<wp:menu_order><?php echo intval( $post->menu_order ); ?></wp:menu_order>
|
||||
<wp:post_parent><?php echo (int) $post->post_parent; ?></wp:post_parent>
|
||||
<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_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 ) : ?>
|
||||
<wp:attachment_url><?php echo wxr_cdata( wp_get_attachment_url( $post->ID ) ); ?></wp:attachment_url>
|
||||
<?php endif; ?>
|
||||
@ -620,7 +620,7 @@ function export_wp( $args = array() ) {
|
||||
foreach ( $comments as $c ) :
|
||||
?>
|
||||
<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_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>
|
||||
@ -630,8 +630,8 @@ function export_wp( $args = array() ) {
|
||||
<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_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_user_id><?php echo intval( $c->user_id ); ?></wp:comment_user_id>
|
||||
<wp:comment_parent><?php echo (int) $c->comment_parent; ?></wp:comment_parent>
|
||||
<wp:comment_user_id><?php echo (int) $c->user_id; ?></wp:comment_user_id>
|
||||
<?php
|
||||
$c_meta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->commentmeta WHERE comment_id = %d", $c->comment_ID ) );
|
||||
foreach ( $c_meta as $meta ) :
|
||||
|
@ -510,7 +510,7 @@ function wp_edit_theme_plugin_file( $args ) {
|
||||
|
||||
$scrape_key = md5( rand() );
|
||||
$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.
|
||||
set_transient( $transient, $scrape_nonce, 60 );
|
||||
|
||||
|
@ -786,8 +786,8 @@ function wp_save_image( $post_id ) {
|
||||
return $return;
|
||||
}
|
||||
|
||||
$fwidth = ! empty( $_REQUEST['fwidth'] ) ? intval( $_REQUEST['fwidth'] ) : 0;
|
||||
$fheight = ! empty( $_REQUEST['fheight'] ) ? intval( $_REQUEST['fheight'] ) : 0;
|
||||
$fwidth = ! empty( $_REQUEST['fwidth'] ) ? (int) $_REQUEST['fwidth'] : 0;
|
||||
$fheight = ! empty( $_REQUEST['fheight'] ) ? (int) $_REQUEST['fheight'] : 0;
|
||||
$target = ! empty( $_REQUEST['target'] ) ? preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['target'] ) : '';
|
||||
$scale = ! empty( $_REQUEST['do'] ) && 'scale' === $_REQUEST['do'];
|
||||
|
||||
@ -944,8 +944,8 @@ function wp_save_image( $post_id ) {
|
||||
}
|
||||
|
||||
if ( isset( $_wp_additional_image_sizes[ $size ] ) ) {
|
||||
$width = intval( $_wp_additional_image_sizes[ $size ]['width'] );
|
||||
$height = intval( $_wp_additional_image_sizes[ $size ]['height'] );
|
||||
$width = (int) $_wp_additional_image_sizes[ $size ]['width'];
|
||||
$height = (int) $_wp_additional_image_sizes[ $size ]['height'];
|
||||
$crop = ( $nocrop ) ? false : $_wp_additional_image_sizes[ $size ]['crop'];
|
||||
} else {
|
||||
$height = get_option( "{$size}_size_h" );
|
||||
|
@ -49,10 +49,10 @@ function update_gallery_tab( $tabs ) {
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
$post_id = intval( $_REQUEST['post_id'] );
|
||||
$post_id = (int) $_REQUEST['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 ) ) {
|
||||
@ -138,7 +138,7 @@ function get_image_send_to_editor( $id, $caption, $title, $align, $url = '', $re
|
||||
if ( is_string( $rel ) ) {
|
||||
$rel = ' rel="' . esc_attr( $rel ) . '"';
|
||||
} else {
|
||||
$rel = ' rel="attachment wp-att-' . intval( $id ) . '"';
|
||||
$rel = ' rel="attachment wp-att-' . (int) $id . '"';
|
||||
}
|
||||
} else {
|
||||
$rel = '';
|
||||
@ -1549,7 +1549,7 @@ function get_media_item( $attachment_id, $args = null ) {
|
||||
global $redir_tab;
|
||||
|
||||
$thumb_url = false;
|
||||
$attachment_id = intval( $attachment_id );
|
||||
$attachment_id = (int) $attachment_id;
|
||||
|
||||
if ( $attachment_id ) {
|
||||
$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
|
||||
*/
|
||||
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>';
|
||||
|
||||
@ -2071,7 +2071,7 @@ function media_upload_form( $errors = null ) {
|
||||
}
|
||||
|
||||
$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 : '';
|
||||
$_tab = isset( $tab ) ? $tab : '';
|
||||
|
||||
@ -2281,7 +2281,7 @@ function media_upload_type_form( $type = 'file', $errors = null, $id = null ) {
|
||||
|
||||
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" );
|
||||
|
||||
@ -2358,7 +2358,7 @@ function media_upload_type_url_form( $type = null, $errors = null, $id = null )
|
||||
|
||||
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" );
|
||||
/** This filter is documented in wp-admin/includes/media.php */
|
||||
@ -2506,7 +2506,7 @@ function media_upload_gallery_form( $errors ) {
|
||||
$redir_tab = 'gallery';
|
||||
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" );
|
||||
/** This filter is documented in wp-admin/includes/media.php */
|
||||
$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();
|
||||
|
||||
$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" );
|
||||
/** This filter is documented in wp-admin/includes/media.php */
|
||||
@ -2682,7 +2682,7 @@ function media_upload_library_form( $errors ) {
|
||||
|
||||
$q = $_GET;
|
||||
$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 ) {
|
||||
$q['paged'] = 1;
|
||||
}
|
||||
@ -2984,9 +2984,9 @@ function media_upload_flash_bypass() {
|
||||
|
||||
$post = get_post();
|
||||
if ( $post ) {
|
||||
$browser_uploader .= '&post_id=' . intval( $post->ID );
|
||||
$browser_uploader .= '&post_id=' . (int) $post->ID;
|
||||
} elseif ( ! empty( $GLOBALS['post_ID'] ) ) {
|
||||
$browser_uploader .= '&post_id=' . intval( $GLOBALS['post_ID'] );
|
||||
$browser_uploader .= '&post_id=' . (int) $GLOBALS['post_ID'];
|
||||
}
|
||||
|
||||
?>
|
||||
@ -3078,7 +3078,7 @@ function edit_form_image_editor( $post ) {
|
||||
}
|
||||
|
||||
$thumb_url = false;
|
||||
$attachment_id = intval( $post->ID );
|
||||
$attachment_id = (int) $post->ID;
|
||||
|
||||
if ( $attachment_id ) {
|
||||
$thumb_url = wp_get_attachment_image_src( $attachment_id, array( 900, 450 ), true );
|
||||
|
@ -382,7 +382,7 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
|
||||
$important_pages[] = $front_page_obj;
|
||||
$suppress_page_ids[] = $front_page_obj->ID;
|
||||
} 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_or_home' => true,
|
||||
'ID' => 0,
|
||||
@ -609,7 +609,7 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
|
||||
$args['walker'] = $walker;
|
||||
|
||||
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(
|
||||
$posts,
|
||||
(object) array(
|
||||
|
@ -1347,10 +1347,11 @@ function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $func
|
||||
|
||||
if ( null === $position ) {
|
||||
$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 {
|
||||
if ( isset( $menu[ $position ] ) ) {
|
||||
$position = $position + substr( base_convert( md5( $menu_slug . $menu_title ), 16, 10 ), -5 ) * 0.00001;
|
||||
}
|
||||
|
||||
$menu[ $position ] = $new_menu;
|
||||
}
|
||||
|
||||
|
@ -1923,7 +1923,7 @@ function post_preview() {
|
||||
}
|
||||
|
||||
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 ) ) {
|
||||
$clean_terms[] = intval( $_term[0] );
|
||||
$clean_terms[] = (int) $_term[0];
|
||||
} else {
|
||||
// No existing term was found, so pass the string. A new term will be created.
|
||||
$clean_terms[] = $term;
|
||||
|
@ -1321,7 +1321,7 @@ function do_meta_boxes( $screen, $context, $object ) {
|
||||
echo '<span aria-hidden="true" class="dashicons dashicons-warning"></span>';
|
||||
echo '<span class="screen-reader-text">' . __( 'Warning:' ) . ' </span>';
|
||||
}
|
||||
echo "{$box['title']}";
|
||||
echo $box['title'];
|
||||
echo "</h2>\n";
|
||||
|
||||
if ( 'dashboard_browser_nag' !== $box['id'] ) {
|
||||
@ -2205,16 +2205,16 @@ function get_post_states( $post ) {
|
||||
}
|
||||
|
||||
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' );
|
||||
}
|
||||
|
||||
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' );
|
||||
}
|
||||
}
|
||||
|
||||
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' );
|
||||
}
|
||||
|
||||
|
@ -1059,7 +1059,7 @@ function wp_get_auto_update_message() {
|
||||
if ( false === $next_update_time ) {
|
||||
$message = __( 'Automatic update not scheduled. There may be a problem with WP-Cron.' );
|
||||
} 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.
|
||||
$overdue = ( time() - $next_update_time ) > 0;
|
||||
|
@ -1022,8 +1022,8 @@ function upgrade_110() {
|
||||
if ( ! $got_gmt_fields ) {
|
||||
|
||||
// Add or subtract time to all dates, to get GMT dates.
|
||||
$add_hours = intval( $diff_gmt_weblogger );
|
||||
$add_minutes = intval( 60 * ( $diff_gmt_weblogger - $add_hours ) );
|
||||
$add_hours = (int) $diff_gmt_weblogger;
|
||||
$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_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'" );
|
||||
@ -2048,7 +2048,7 @@ function upgrade_430_fix_comments() {
|
||||
return;
|
||||
}
|
||||
|
||||
$allowed_length = intval( $content_length['length'] ) - 10;
|
||||
$allowed_length = (int) $content_length['length'] - 10;
|
||||
|
||||
$comments = $wpdb->get_results(
|
||||
"SELECT `comment_ID` FROM `{$wpdb->comments}`
|
||||
|
@ -51,7 +51,7 @@ if ( ! empty( $_REQUEST['post_id'] ) && ! current_user_can( 'edit_post', $_REQUE
|
||||
|
||||
// Upload type: image, video, file, ...?
|
||||
if ( isset( $_GET['type'] ) ) {
|
||||
$type = strval( $_GET['type'] );
|
||||
$type = (string) $_GET['type'];
|
||||
} else {
|
||||
/**
|
||||
* 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.
|
||||
if ( isset( $_GET['tab'] ) ) {
|
||||
$tab = strval( $_GET['tab'] );
|
||||
$tab = (string) $_GET['tab'];
|
||||
} else {
|
||||
/**
|
||||
* Filters the default tab in the legacy (pre-3.5.0) media popup.
|
||||
|
@ -424,7 +424,7 @@ switch ( $action ) {
|
||||
|
||||
// If the menu ID changed, redirect to the new URL.
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -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()->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 ) {
|
||||
wp_die( __( 'Invalid site ID.' ) );
|
||||
|
@ -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()->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 ) {
|
||||
wp_die( __( 'Invalid site ID.' ) );
|
||||
|
@ -40,7 +40,7 @@ if ( ! empty( $_REQUEST['paged'] ) ) {
|
||||
$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 ) {
|
||||
wp_die( __( 'Invalid site ID.' ) );
|
||||
|
@ -35,7 +35,7 @@ if ( ! empty( $_REQUEST['paged'] ) ) {
|
||||
$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 ) {
|
||||
wp_die( __( 'Invalid site ID.' ) );
|
||||
|
@ -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'] ) ) {
|
||||
/** This action is documented in wp-admin/network/edit.php */
|
||||
|
@ -45,7 +45,7 @@ $action = isset( $_GET['action'] ) ? $_GET['action'] : 'show';
|
||||
|
||||
switch ( $action ) {
|
||||
case 'upgrade':
|
||||
$n = ( isset( $_GET['n'] ) ) ? intval( $_GET['n'] ) : 0;
|
||||
$n = ( isset( $_GET['n'] ) ) ? (int) $_GET['n'] : 0;
|
||||
|
||||
if ( $n < 5 ) {
|
||||
/**
|
||||
|
@ -26,7 +26,7 @@ if ( isset( $_GET['action'] ) ) {
|
||||
|
||||
check_admin_referer( 'deleteuser' );
|
||||
|
||||
$id = intval( $_GET['id'] );
|
||||
$id = (int) $_GET['id'];
|
||||
if ( $id > 1 ) {
|
||||
$_POST['allusers'] = array( $id ); // confirm_delete_users() can only handle arrays.
|
||||
$title = __( 'Users' );
|
||||
|
@ -230,7 +230,7 @@ switch ( $wp_list_table->current_action() ) {
|
||||
}
|
||||
|
||||
if ( empty( $_REQUEST['users'] ) ) {
|
||||
$userids = array( intval( $_REQUEST['user'] ) );
|
||||
$userids = array( (int) $_REQUEST['user'] );
|
||||
} else {
|
||||
$userids = array_map( 'intval', (array) $_REQUEST['users'] );
|
||||
}
|
||||
@ -401,7 +401,7 @@ switch ( $wp_list_table->current_action() ) {
|
||||
}
|
||||
|
||||
if ( empty( $_REQUEST['users'] ) ) {
|
||||
$userids = array( intval( $_REQUEST['user'] ) );
|
||||
$userids = array( (int) $_REQUEST['user'] );
|
||||
} else {
|
||||
$userids = $_REQUEST['users'];
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ nocache_headers();
|
||||
|
||||
$comment = wp_handle_comment_submission( wp_unslash( $_POST ) );
|
||||
if ( is_wp_error( $comment ) ) {
|
||||
$data = intval( $comment->get_error_data() );
|
||||
$data = (int) $comment->get_error_data();
|
||||
if ( ! empty( $data ) ) {
|
||||
wp_die(
|
||||
'<p>' . $comment->get_error_message() . '</p>',
|
||||
|
@ -24,7 +24,7 @@ if ( ! function_exists( 'twentyfourteen_paging_nav' ) ) :
|
||||
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() );
|
||||
$query_args = array();
|
||||
$url_parts = explode( '?', $pagenum_link );
|
||||
|
@ -433,7 +433,7 @@ function wp_dropdown_categories( $args = '' ) {
|
||||
|
||||
/** This filter is documented in wp-includes/category-template.php */
|
||||
$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";
|
||||
}
|
||||
|
||||
@ -737,7 +737,7 @@ function wp_tag_cloud( $args = '' ) {
|
||||
if ( 'edit' === $args['link'] ) {
|
||||
$link = get_edit_term_link( $tag->term_id, $tag->taxonomy, $args['post_type'] );
|
||||
} 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 ) ) {
|
||||
|
@ -752,7 +752,7 @@ class WP_Http {
|
||||
}
|
||||
|
||||
// Cast the Response Code to an int.
|
||||
$response['code'] = intval( $response['code'] );
|
||||
$response['code'] = (int) $response['code'];
|
||||
|
||||
return array(
|
||||
'response' => $response,
|
||||
|
@ -579,7 +579,7 @@ class Services_JSON
|
||||
return $encoded_value;
|
||||
}
|
||||
|
||||
return $this->_encode(strval($name)) . ':' . $encoded_value;
|
||||
return $this->_encode((string) $name) . ':' . $encoded_value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -456,7 +456,7 @@ class WP_Comment_Query {
|
||||
// If querying for a count only, there's nothing more to do.
|
||||
if ( $this->query_vars['count'] ) {
|
||||
// $comment_ids is actually a count in this case.
|
||||
return intval( $comment_ids );
|
||||
return (int) $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']}";
|
||||
|
||||
if ( $this->query_vars['count'] ) {
|
||||
return intval( $wpdb->get_var( $this->request ) );
|
||||
return (int) $wpdb->get_var( $this->request );
|
||||
} else {
|
||||
$comment_ids = $wpdb->get_col( $this->request );
|
||||
return array_map( 'intval', $comment_ids );
|
||||
|
@ -1463,7 +1463,7 @@ final class WP_Customize_Manager {
|
||||
preg_match( '#^nav_menu\[(?P<nav_menu_id>-?\d+)\]$#', $setting_id, $matches )
|
||||
);
|
||||
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;
|
||||
$reused_nav_menu_setting_ids[] = $setting_id;
|
||||
break;
|
||||
@ -3268,7 +3268,7 @@ final class WP_Customize_Manager {
|
||||
$lock = explode( ':', $lock );
|
||||
|
||||
if ( $lock && ! empty( $lock[1] ) ) {
|
||||
$user_id = intval( $lock[1] );
|
||||
$user_id = (int) $lock[1];
|
||||
$current_user_id = get_current_user_id();
|
||||
if ( $user_id === $current_user_id ) {
|
||||
$lock = sprintf( '%s:%s', time(), $user_id );
|
||||
|
@ -249,8 +249,8 @@ final class WP_Customize_Nav_Menus {
|
||||
'type' => 'post_type',
|
||||
'type_label' => $post_type_label,
|
||||
'object' => $post->post_type,
|
||||
'object_id' => intval( $post->ID ),
|
||||
'url' => get_permalink( intval( $post->ID ) ),
|
||||
'object_id' => (int) $post->ID,
|
||||
'url' => get_permalink( (int) $post->ID ),
|
||||
);
|
||||
}
|
||||
} elseif ( 'taxonomy' === $type ) {
|
||||
@ -281,8 +281,8 @@ final class WP_Customize_Nav_Menus {
|
||||
'type' => 'taxonomy',
|
||||
'type_label' => get_taxonomy( $term->taxonomy )->labels->singular_name,
|
||||
'object' => $term->taxonomy,
|
||||
'object_id' => intval( $term->term_id ),
|
||||
'url' => get_term_link( intval( $term->term_id ), $term->taxonomy ),
|
||||
'object_id' => (int) $term->term_id,
|
||||
'url' => get_term_link( (int) $term->term_id, $term->taxonomy ),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -410,8 +410,8 @@ final class WP_Customize_Nav_Menus {
|
||||
'type' => 'post_type',
|
||||
'type_label' => $post_type_label,
|
||||
'object' => $post->post_type,
|
||||
'object_id' => intval( $post->ID ),
|
||||
'url' => get_permalink( intval( $post->ID ) ),
|
||||
'object_id' => (int) $post->ID,
|
||||
'url' => get_permalink( (int) $post->ID ),
|
||||
);
|
||||
}
|
||||
|
||||
@ -436,8 +436,8 @@ final class WP_Customize_Nav_Menus {
|
||||
'type' => 'taxonomy',
|
||||
'type_label' => get_taxonomy( $term->taxonomy )->labels->singular_name,
|
||||
'object' => $term->taxonomy,
|
||||
'object_id' => intval( $term->term_id ),
|
||||
'url' => get_term_link( intval( $term->term_id ), $term->taxonomy ),
|
||||
'object_id' => (int) $term->term_id,
|
||||
'url' => get_term_link( (int) $term->term_id, $term->taxonomy ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -605,7 +605,7 @@ final class WP_Customize_Widgets {
|
||||
|
||||
if ( preg_match( '/^(.+)-(\d+)$/', $widget_id, $matches ) ) {
|
||||
$parsed['id_base'] = $matches[1];
|
||||
$parsed['number'] = intval( $matches[2] );
|
||||
$parsed['number'] = (int) $matches[2];
|
||||
} else {
|
||||
// Likely an old single widget.
|
||||
$parsed['id_base'] = $widget_id;
|
||||
@ -628,7 +628,7 @@ final class WP_Customize_Widgets {
|
||||
}
|
||||
|
||||
$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' );
|
||||
}
|
||||
@ -1772,7 +1772,7 @@ final class WP_Customize_Widgets {
|
||||
}
|
||||
$this->sidebar_instance_count[ $index ] += 1;
|
||||
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 ) {
|
||||
array_shift( $this->current_dynamic_sidebar_id_stack );
|
||||
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'];
|
||||
|
||||
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.
|
||||
|
@ -874,32 +874,32 @@ class WP_Date_Query {
|
||||
if ( preg_match( '/^(\d{4})$/', $datetime, $matches ) ) {
|
||||
// Y
|
||||
$datetime = array(
|
||||
'year' => intval( $matches[1] ),
|
||||
'year' => (int) $matches[1],
|
||||
);
|
||||
|
||||
} elseif ( preg_match( '/^(\d{4})\-(\d{2})$/', $datetime, $matches ) ) {
|
||||
// Y-m
|
||||
$datetime = array(
|
||||
'year' => intval( $matches[1] ),
|
||||
'month' => intval( $matches[2] ),
|
||||
'year' => (int) $matches[1],
|
||||
'month' => (int) $matches[2],
|
||||
);
|
||||
|
||||
} elseif ( preg_match( '/^(\d{4})\-(\d{2})\-(\d{2})$/', $datetime, $matches ) ) {
|
||||
// Y-m-d
|
||||
$datetime = array(
|
||||
'year' => intval( $matches[1] ),
|
||||
'month' => intval( $matches[2] ),
|
||||
'day' => intval( $matches[3] ),
|
||||
'year' => (int) $matches[1],
|
||||
'month' => (int) $matches[2],
|
||||
'day' => (int) $matches[3],
|
||||
);
|
||||
|
||||
} elseif ( preg_match( '/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2})$/', $datetime, $matches ) ) {
|
||||
// Y-m-d H:i
|
||||
$datetime = array(
|
||||
'year' => intval( $matches[1] ),
|
||||
'month' => intval( $matches[2] ),
|
||||
'day' => intval( $matches[3] ),
|
||||
'hour' => intval( $matches[4] ),
|
||||
'minute' => intval( $matches[5] ),
|
||||
'year' => (int) $matches[1],
|
||||
'month' => (int) $matches[2],
|
||||
'day' => (int) $matches[3],
|
||||
'hour' => (int) $matches[4],
|
||||
'minute' => (int) $matches[5],
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ class WP_Http_Curl {
|
||||
curl_setopt( $handle, CURLOPT_HEADER, false );
|
||||
|
||||
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 {
|
||||
$this->max_body_length = false;
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ class WP_MatchesMapRegex {
|
||||
* @return string
|
||||
*/
|
||||
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 ] ) : '' );
|
||||
}
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ class WP_Network_Query {
|
||||
// If querying for a count only, there's nothing more to do.
|
||||
if ( $this->query_vars['count'] ) {
|
||||
// $network_ids is actually a count in this case.
|
||||
return intval( $network_ids );
|
||||
return (int) $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']}";
|
||||
|
||||
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 );
|
||||
|
@ -763,7 +763,7 @@ class WP_Query {
|
||||
$qv['p'] = 0;
|
||||
$qv['error'] = '404';
|
||||
} else {
|
||||
$qv['p'] = intval( $qv['p'] );
|
||||
$qv['p'] = (int) $qv['p'];
|
||||
}
|
||||
|
||||
$qv['page_id'] = absint( $qv['page_id'] );
|
||||
@ -942,7 +942,7 @@ class WP_Query {
|
||||
$this->is_trackback = true;
|
||||
}
|
||||
|
||||
if ( '' != $qv['paged'] && ( intval( $qv['paged'] ) > 1 ) ) {
|
||||
if ( '' != $qv['paged'] && ( (int) $qv['paged'] > 1 ) ) {
|
||||
$this->is_paged = true;
|
||||
}
|
||||
|
||||
@ -1604,7 +1604,7 @@ class WP_Query {
|
||||
// If RAND() contains a seed value, sanitize and add to allowed keys.
|
||||
$rand_with_seed = false;
|
||||
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;
|
||||
$rand_with_seed = true;
|
||||
}
|
||||
@ -2263,7 +2263,7 @@ class WP_Query {
|
||||
// Numeric comment count is converted to array format.
|
||||
if ( is_numeric( $q['comment_count'] ) ) {
|
||||
$q['comment_count'] = array(
|
||||
'value' => intval( $q['comment_count'] ),
|
||||
'value' => (int) $q['comment_count'],
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -351,7 +351,7 @@ class WP_Site_Query {
|
||||
// If querying for a count only, there's nothing more to do.
|
||||
if ( $this->query_vars['count'] ) {
|
||||
// $site_ids is actually a count in this case.
|
||||
return intval( $site_ids );
|
||||
return (int) $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']}";
|
||||
|
||||
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 );
|
||||
|
@ -258,7 +258,7 @@ class WP_Term_Query {
|
||||
$query['offset'] = absint( $query['offset'] );
|
||||
|
||||
// 'parent' overrides 'child_of'.
|
||||
if ( 0 < intval( $query['parent'] ) ) {
|
||||
if ( 0 < (int) $query['parent'] ) {
|
||||
$query['child_of'] = false;
|
||||
}
|
||||
|
||||
@ -346,7 +346,7 @@ class WP_Term_Query {
|
||||
}
|
||||
|
||||
// 'parent' overrides 'child_of'.
|
||||
if ( 0 < intval( $args['parent'] ) ) {
|
||||
if ( 0 < (int) $args['parent'] ) {
|
||||
$args['child_of'] = false;
|
||||
}
|
||||
|
||||
@ -443,7 +443,7 @@ class WP_Term_Query {
|
||||
(array) get_terms(
|
||||
array(
|
||||
'taxonomy' => reset( $taxonomies ),
|
||||
'child_of' => intval( $extrunk ),
|
||||
'child_of' => (int) $extrunk,
|
||||
'fields' => 'ids',
|
||||
'hide_empty' => 0,
|
||||
)
|
||||
|
@ -199,7 +199,7 @@ class WP_User {
|
||||
if ( ! is_numeric( $value ) ) {
|
||||
return false;
|
||||
}
|
||||
$value = intval( $value );
|
||||
$value = (int) $value;
|
||||
if ( $value < 1 ) {
|
||||
return false;
|
||||
}
|
||||
@ -645,7 +645,7 @@ class WP_User {
|
||||
*/
|
||||
public function level_reduction( $max, $item ) {
|
||||
if ( preg_match( '/^level_(10|[0-9])$/i', $item, $matches ) ) {
|
||||
$level = intval( $matches[1] );
|
||||
$level = (int) $matches[1];
|
||||
return max( $max, $level );
|
||||
} else {
|
||||
return $max;
|
||||
|
@ -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.
|
||||
$_term['term_id'] = strval( $_term['term_id'] );
|
||||
$_term['term_group'] = strval( $_term['term_group'] );
|
||||
$_term['term_taxonomy_id'] = strval( $_term['term_taxonomy_id'] );
|
||||
$_term['parent'] = strval( $_term['parent'] );
|
||||
$_term['term_id'] = (string) $_term['term_id'];
|
||||
$_term['term_group'] = (string) $_term['term_group'];
|
||||
$_term['term_taxonomy_id'] = (string) $_term['term_taxonomy_id'];
|
||||
$_term['parent'] = (string) $_term['parent'];
|
||||
|
||||
// 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.
|
||||
$_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 ) {
|
||||
// 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.
|
||||
$post_fields = array(
|
||||
@ -872,11 +872,11 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
'post_password' => $post['post_password'],
|
||||
'post_excerpt' => $post['post_excerpt'],
|
||||
'post_content' => $post['post_content'],
|
||||
'post_parent' => strval( $post['post_parent'] ),
|
||||
'post_parent' => (string) $post['post_parent'],
|
||||
'post_mime_type' => $post['post_mime_type'],
|
||||
'link' => get_permalink( $post['ID'] ),
|
||||
'guid' => $post['guid'],
|
||||
'menu_order' => intval( $post['menu_order'] ),
|
||||
'menu_order' => (int) $post['menu_order'],
|
||||
'comment_status' => $post['comment_status'],
|
||||
'ping_status' => $post['ping_status'],
|
||||
'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' ) {
|
||||
$_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 ),
|
||||
'parent' => $media_item->post_parent,
|
||||
'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.
|
||||
*/
|
||||
protected function _prepare_user( $user, $fields ) {
|
||||
$_user = array( 'user_id' => strval( $user->ID ) );
|
||||
$_user = array( 'user_id' => (string) $user->ID );
|
||||
|
||||
$user_fields = array(
|
||||
'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'] );
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
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' );
|
||||
|
||||
$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.
|
||||
$isPrimary = true;
|
||||
foreach ( $catids as $catid ) {
|
||||
@ -6812,7 +6812,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
$post_ID = (int) $blah[1];
|
||||
} elseif ( isset( $urltest['fragment'] ) ) {
|
||||
// An #anchor is there, it's either...
|
||||
if ( intval( $urltest['fragment'] ) ) {
|
||||
if ( (int) $urltest['fragment'] ) {
|
||||
// ...an integer #XXXX (simplest case),
|
||||
$post_ID = (int) $urltest['fragment'];
|
||||
} elseif ( preg_match( '/post-[0-9]+/', $urltest['fragment'] ) ) {
|
||||
|
@ -604,7 +604,7 @@ function get_comment_excerpt( $comment_ID = 0 ) {
|
||||
}
|
||||
|
||||
/* 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.
|
||||
@ -2205,7 +2205,7 @@ function wp_list_comments( $args = array(), $comments = null ) {
|
||||
}
|
||||
}
|
||||
// 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'] ) {
|
||||
$parsed_args['page'] = 1;
|
||||
}
|
||||
|
@ -1254,7 +1254,7 @@ function wp_get_comment_fields_max_lengths() {
|
||||
|
||||
if ( ! is_array( $col_length ) && (int) $col_length > 0 ) {
|
||||
$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'];
|
||||
|
||||
if ( ! empty( $col_length['type'] ) && 'byte' === $col_length['type'] ) {
|
||||
|
@ -81,8 +81,8 @@ class WP_Customize_Date_Time_Control extends WP_Customize_Control {
|
||||
public function json() {
|
||||
$data = parent::json();
|
||||
|
||||
$data['maxYear'] = intval( $this->max_year );
|
||||
$data['minYear'] = intval( $this->min_year );
|
||||
$data['maxYear'] = (int) $this->max_year;
|
||||
$data['minYear'] = (int) $this->min_year;
|
||||
$data['allowPastDate'] = (bool) $this->allow_past_date;
|
||||
$data['twelveHourFormat'] = (bool) $this->twelve_hour_format;
|
||||
$data['includeTime'] = (bool) $this->include_time;
|
||||
@ -245,7 +245,7 @@ class WP_Customize_Date_Time_Control extends WP_Customize_Control {
|
||||
$timezone_info['description'] = '';
|
||||
}
|
||||
} 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(
|
||||
/* translators: 1: UTC abbreviation and offset, 2: UTC offset. */
|
||||
|
@ -171,7 +171,7 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
|
||||
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 );
|
||||
|
||||
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 ) {
|
||||
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 ) {
|
||||
@ -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 = 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 ) {
|
||||
// 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 ) {
|
||||
@ -798,7 +798,7 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
|
||||
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_error = new WP_Error( 'unexpected_previous_term_id' );
|
||||
return;
|
||||
@ -824,7 +824,7 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
|
||||
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_error = new WP_Error( 'unexpected_previous_post_id' );
|
||||
return;
|
||||
|
@ -34,7 +34,7 @@ class WP_Customize_Nav_Menu_Section extends WP_Customize_Section {
|
||||
*/
|
||||
public function 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;
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ class WP_Customize_Nav_Menu_Setting extends WP_Customize_Setting {
|
||||
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 );
|
||||
}
|
||||
@ -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['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'] );
|
||||
|
||||
if ( '' === $value['name'] ) {
|
||||
@ -556,7 +556,7 @@ class WP_Customize_Nav_Menu_Setting extends WP_Customize_Setting {
|
||||
}
|
||||
|
||||
$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 );
|
||||
$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().
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -3568,8 +3568,8 @@ function iso8601_timezone_to_offset( $timezone ) {
|
||||
$offset = 0;
|
||||
} else {
|
||||
$sign = ( '+' === substr( $timezone, 0, 1 ) ) ? 1 : -1;
|
||||
$hours = intval( substr( $timezone, 1, 2 ) );
|
||||
$minutes = intval( substr( $timezone, 3, 4 ) ) / 60;
|
||||
$hours = (int) substr( $timezone, 1, 2 );
|
||||
$minutes = (int) substr( $timezone, 3, 4 ) / 60;
|
||||
$offset = $sign * HOUR_IN_SECONDS * ( $hours + $minutes );
|
||||
}
|
||||
return $offset;
|
||||
@ -3820,7 +3820,7 @@ function wp_trim_excerpt( $text = '', $post = null ) {
|
||||
$text = str_replace( ']]>', ']]>', $text );
|
||||
|
||||
/* 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.
|
||||
@ -4725,7 +4725,7 @@ function sanitize_option( $option, $value ) {
|
||||
if ( null === $value ) {
|
||||
$value = 1;
|
||||
} else {
|
||||
$value = intval( $value );
|
||||
$value = (int) $value;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -5067,7 +5067,7 @@ function wp_sprintf( $pattern, ...$args ) {
|
||||
if ( $_fragment != $fragment ) {
|
||||
$fragment = $_fragment;
|
||||
} else {
|
||||
$fragment = sprintf( $fragment, strval( $arg ) );
|
||||
$fragment = sprintf( $fragment, (string) $arg );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4735,7 +4735,7 @@ function dead_db() {
|
||||
* @return int A non-negative integer.
|
||||
*/
|
||||
function absint( $maybeint ) {
|
||||
return abs( intval( $maybeint ) );
|
||||
return abs( (int) $maybeint );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1339,7 +1339,7 @@ function wp_title( $sep = '»', $display = true, $seplocation = '' ) {
|
||||
if ( is_archive() && ! empty( $m ) ) {
|
||||
$my_year = substr( $m, 0, 4 );
|
||||
$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 : '' );
|
||||
}
|
||||
|
||||
@ -2223,7 +2223,7 @@ function get_calendar( $initial = true, $echo = true ) {
|
||||
|
||||
// Let's figure out when we are.
|
||||
if ( ! empty( $monthnum ) && ! empty( $year ) ) {
|
||||
$thismonth = zeroise( intval( $monthnum ), 2 );
|
||||
$thismonth = zeroise( (int) $monthnum, 2 );
|
||||
$thisyear = (int) $year;
|
||||
} elseif ( ! empty( $w ) ) {
|
||||
// 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 );
|
||||
}
|
||||
} 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 ) );
|
||||
$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 ( $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 ) {
|
||||
$wp_rich_edit = ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Trident/7.0;' ) !== false );
|
||||
} 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.
|
||||
$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.
|
||||
$pagenum_link = trailingslashit( $url_parts[0] ) . '%_%';
|
||||
|
@ -668,7 +668,7 @@ function ms_allowed_http_request_hosts( $is_external, $host ) {
|
||||
*/
|
||||
function wp_parse_url( $url, $component = -1 ) {
|
||||
$to_unset = array();
|
||||
$url = strval( $url );
|
||||
$url = (string) $url;
|
||||
|
||||
if ( '//' === substr( $url, 0, 2 ) ) {
|
||||
$to_unset[] = 'scheme';
|
||||
|
@ -515,7 +515,7 @@ function get_month_link( $year, $month ) {
|
||||
$monthlink = $wp_rewrite->get_month_permastruct();
|
||||
if ( ! empty( $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' ) );
|
||||
} else {
|
||||
$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();
|
||||
if ( ! empty( $daylink ) ) {
|
||||
$daylink = str_replace( '%year%', $year, $daylink );
|
||||
$daylink = str_replace( '%monthnum%', zeroise( intval( $month ), 2 ), $daylink );
|
||||
$daylink = str_replace( '%day%', zeroise( intval( $day ), 2 ), $daylink );
|
||||
$daylink = str_replace( '%monthnum%', zeroise( (int) $month, 2 ), $daylink );
|
||||
$daylink = str_replace( '%day%', zeroise( (int) $day, 2 ), $daylink );
|
||||
$daylink = home_url( user_trailingslashit( $daylink, 'day' ) );
|
||||
} else {
|
||||
$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 ) {
|
||||
$paged = 1;
|
||||
}
|
||||
$nextpage = intval( $paged ) + 1;
|
||||
$nextpage = (int) $paged + 1;
|
||||
if ( ! $max_page || $max_page >= $nextpage ) {
|
||||
return get_pagenum_link( $nextpage );
|
||||
}
|
||||
@ -2369,7 +2369,7 @@ function get_next_posts_link( $label = null, $max_page = 0 ) {
|
||||
$paged = 1;
|
||||
}
|
||||
|
||||
$nextpage = intval( $paged ) + 1;
|
||||
$nextpage = (int) $paged + 1;
|
||||
|
||||
if ( null === $label ) {
|
||||
$label = __( 'Next Page »' );
|
||||
@ -2418,7 +2418,7 @@ function get_previous_posts_page_link() {
|
||||
global $paged;
|
||||
|
||||
if ( ! is_single() ) {
|
||||
$nextpage = intval( $paged ) - 1;
|
||||
$nextpage = (int) $paged - 1;
|
||||
if ( $nextpage < 1 ) {
|
||||
$nextpage = 1;
|
||||
}
|
||||
@ -2891,7 +2891,7 @@ function get_next_comments_link( $label = '', $max_page = 0 ) {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$nextpage = intval( $page ) + 1;
|
||||
$nextpage = (int) $page + 1;
|
||||
|
||||
if ( empty( $max_page ) ) {
|
||||
$max_page = $wp_query->max_num_comment_pages;
|
||||
@ -2946,11 +2946,11 @@ function get_previous_comments_link( $label = '' ) {
|
||||
|
||||
$page = get_query_var( 'cpage' );
|
||||
|
||||
if ( intval( $page ) <= 1 ) {
|
||||
if ( (int) $page <= 1 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$prevpage = intval( $page ) - 1;
|
||||
$prevpage = (int) $page - 1;
|
||||
|
||||
if ( empty( $label ) ) {
|
||||
$label = __( '« Older Comments' );
|
||||
|
@ -70,23 +70,23 @@ function image_constrain_size_for_editor( $width, $height, $size = 'medium', $co
|
||||
$max_width = $size[0];
|
||||
$max_height = $size[1];
|
||||
} elseif ( 'thumb' === $size || 'thumbnail' === $size ) {
|
||||
$max_width = intval( get_option( 'thumbnail_size_w' ) );
|
||||
$max_height = intval( get_option( 'thumbnail_size_h' ) );
|
||||
$max_width = (int) get_option( 'thumbnail_size_w' );
|
||||
$max_height = (int) get_option( 'thumbnail_size_h' );
|
||||
// Last chance thumbnail size defaults.
|
||||
if ( ! $max_width && ! $max_height ) {
|
||||
$max_width = 128;
|
||||
$max_height = 96;
|
||||
}
|
||||
} elseif ( 'medium' === $size ) {
|
||||
$max_width = intval( get_option( 'medium_size_w' ) );
|
||||
$max_height = intval( get_option( 'medium_size_h' ) );
|
||||
$max_width = (int) get_option( 'medium_size_w' );
|
||||
$max_height = (int) get_option( 'medium_size_h' );
|
||||
|
||||
} elseif ( 'medium_large' === $size ) {
|
||||
$max_width = intval( get_option( 'medium_large_size_w' ) );
|
||||
$max_height = intval( get_option( 'medium_large_size_h' ) );
|
||||
$max_width = (int) get_option( 'medium_large_size_w' );
|
||||
$max_height = (int) get_option( 'medium_large_size_h' );
|
||||
|
||||
if ( intval( $content_width ) > 0 ) {
|
||||
$max_width = min( intval( $content_width ), $max_width );
|
||||
if ( (int) $content_width > 0 ) {
|
||||
$max_width = min( (int) $content_width, $max_width );
|
||||
}
|
||||
} 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
|
||||
* can resize it in the editor if they wish.
|
||||
*/
|
||||
$max_width = intval( get_option( 'large_size_w' ) );
|
||||
$max_height = intval( get_option( 'large_size_h' ) );
|
||||
$max_width = (int) get_option( 'large_size_w' );
|
||||
$max_height = (int) get_option( 'large_size_h' );
|
||||
|
||||
if ( intval( $content_width ) > 0 ) {
|
||||
$max_width = min( intval( $content_width ), $max_width );
|
||||
if ( (int) $content_width > 0 ) {
|
||||
$max_width = min( (int) $content_width, $max_width );
|
||||
}
|
||||
} 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_height = intval( $_wp_additional_image_sizes[ $size ]['height'] );
|
||||
$max_width = (int) $_wp_additional_image_sizes[ $size ]['width'];
|
||||
$max_height = (int) $_wp_additional_image_sizes[ $size ]['height'];
|
||||
// Only in admin. Assume that theme authors know what they're doing.
|
||||
if ( intval( $content_width ) > 0 && 'edit' === $context ) {
|
||||
$max_width = min( intval( $content_width ), $max_width );
|
||||
if ( (int) $content_width > 0 && 'edit' === $context ) {
|
||||
$max_width = min( (int) $content_width, $max_width );
|
||||
}
|
||||
} else { // $size === 'full' has no constraint.
|
||||
$max_width = $width;
|
||||
@ -155,10 +155,10 @@ function image_constrain_size_for_editor( $width, $height, $size = 'medium', $co
|
||||
function image_hwstring( $width, $height ) {
|
||||
$out = '';
|
||||
if ( $width ) {
|
||||
$out .= 'width="' . intval( $width ) . '" ';
|
||||
$out .= 'width="' . (int) $width . '" ';
|
||||
}
|
||||
if ( $height ) {
|
||||
$out .= 'height="' . intval( $height ) . '" ';
|
||||
$out .= 'height="' . (int) $height . '" ';
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
@ -775,7 +775,7 @@ function image_get_intermediate_size( $post_id, $size = 'thumbnail' ) {
|
||||
|
||||
foreach ( $imagedata['sizes'] as $_size => $data ) {
|
||||
// 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;
|
||||
break;
|
||||
}
|
||||
@ -896,16 +896,16 @@ function wp_get_registered_image_subsizes() {
|
||||
|
||||
if ( isset( $additional_sizes[ $size_name ]['width'] ) ) {
|
||||
// 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 {
|
||||
// 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'] ) ) {
|
||||
$size_data['height'] = intval( $additional_sizes[ $size_name ]['height'] );
|
||||
$size_data['height'] = (int) $additional_sizes[ $size_name ]['height'];
|
||||
} 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'] ) ) {
|
||||
@ -2215,7 +2215,7 @@ function gallery_shortcode( $attr ) {
|
||||
'gallery'
|
||||
);
|
||||
|
||||
$id = intval( $atts['id'] );
|
||||
$id = (int) $atts['id'];
|
||||
|
||||
if ( ! empty( $atts['include'] ) ) {
|
||||
$_attachments = get_posts(
|
||||
@ -2293,7 +2293,7 @@ function gallery_shortcode( $attr ) {
|
||||
$icontag = 'dt';
|
||||
}
|
||||
|
||||
$columns = intval( $atts['columns'] );
|
||||
$columns = (int) $atts['columns'];
|
||||
$itemwidth = $columns > 0 ? floor( 100 / $columns ) : 100;
|
||||
$float = is_rtl() ? 'right' : 'left';
|
||||
|
||||
@ -2553,7 +2553,7 @@ function wp_playlist_shortcode( $attr ) {
|
||||
'playlist'
|
||||
);
|
||||
|
||||
$id = intval( $atts['id'] );
|
||||
$id = (int) $atts['id'];
|
||||
|
||||
if ( 'audio' !== $atts['type'] ) {
|
||||
$atts['type'] = 'video';
|
||||
@ -3330,7 +3330,7 @@ function adjacent_image_link( $prev = true, $size = 'thumbnail', $text = false )
|
||||
);
|
||||
|
||||
foreach ( $attachments as $k => $attachment ) {
|
||||
if ( intval( $attachment->ID ) === intval( $post->ID ) ) {
|
||||
if ( (int) $attachment->ID === (int) $post->ID ) {
|
||||
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.
|
||||
if ( ! isset( $shortcode_attrs['id'] ) ) {
|
||||
$shortcode[3] .= ' id="' . intval( $post->ID ) . '"';
|
||||
$shortcode[3] .= ' id="' . (int) $post->ID . '"';
|
||||
}
|
||||
|
||||
$gallery = do_shortcode_tag( $shortcode );
|
||||
|
@ -722,7 +722,7 @@ function get_metadata_by_mid( $meta_type, $meta_id ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$meta_id = intval( $meta_id );
|
||||
$meta_id = (int) $meta_id;
|
||||
if ( $meta_id <= 0 ) {
|
||||
return false;
|
||||
}
|
||||
@ -786,7 +786,7 @@ function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key =
|
||||
return false;
|
||||
}
|
||||
|
||||
$meta_id = intval( $meta_id );
|
||||
$meta_id = (int) $meta_id;
|
||||
if ( $meta_id <= 0 ) {
|
||||
return false;
|
||||
}
|
||||
@ -901,7 +901,7 @@ function delete_metadata_by_mid( $meta_type, $meta_id ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$meta_id = intval( $meta_id );
|
||||
$meta_id = (int) $meta_id;
|
||||
if ( $meta_id <= 0 ) {
|
||||
return false;
|
||||
}
|
||||
@ -1062,7 +1062,7 @@ function update_meta_cache( $meta_type, $object_ids ) {
|
||||
|
||||
if ( ! empty( $meta_list ) ) {
|
||||
foreach ( $meta_list as $metarow ) {
|
||||
$mpid = intval( $metarow[ $column ] );
|
||||
$mpid = (int) $metarow[ $column ];
|
||||
$mkey = $metarow['meta_key'];
|
||||
$mval = $metarow['meta_value'];
|
||||
|
||||
|
@ -708,7 +708,7 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) {
|
||||
$mydomain = $blogname . '.' . preg_replace( '|^www\.|', '', $domain );
|
||||
$path = $base;
|
||||
} else {
|
||||
$mydomain = "$domain";
|
||||
$mydomain = $domain;
|
||||
$path = $base . $blogname . '/';
|
||||
}
|
||||
if ( domain_exists( $mydomain, $path, $current_network->id ) ) {
|
||||
@ -1970,7 +1970,7 @@ function global_terms( $term_id, $deprecated = '' ) {
|
||||
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 ) );
|
||||
|
||||
$global_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM $wpdb->sitecategories WHERE category_nicename = %s", $c->slug ) );
|
||||
|
@ -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;
|
||||
|
||||
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_object_id', strval( (int) $args['menu-item-object-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', (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_target', sanitize_key( $args['menu-item-target'] ) );
|
||||
|
||||
|
@ -2540,7 +2540,7 @@ if ( ! function_exists( 'wp_rand' ) ) :
|
||||
$value = $min + ( $max - $min + 1 ) * $value / ( $max_random_number + 1 );
|
||||
}
|
||||
|
||||
return abs( intval( $value ) );
|
||||
return abs( (int) $value );
|
||||
}
|
||||
endif;
|
||||
|
||||
|
@ -4135,7 +4135,7 @@ function wp_insert_post( $postarr, $wp_error = false ) {
|
||||
}
|
||||
|
||||
if ( $thumbnail_support ) {
|
||||
$thumbnail_id = intval( $postarr['_thumbnail_id'] );
|
||||
$thumbnail_id = (int) $postarr['_thumbnail_id'];
|
||||
if ( -1 === $thumbnail_id ) {
|
||||
delete_post_thumbnail( $post_ID );
|
||||
} 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.
|
||||
$conflicts_with_date_archive = false;
|
||||
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 ) {
|
||||
$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.
|
||||
$children = array();
|
||||
foreach ( (array) $pages as $page ) {
|
||||
$children[ intval( $page->post_parent ) ][] = $page;
|
||||
$children[ (int) $page->post_parent ][] = $page;
|
||||
}
|
||||
|
||||
$page_list = array();
|
||||
@ -5310,7 +5310,7 @@ function get_page_hierarchy( &$pages, $page_id = 0 ) {
|
||||
|
||||
$children = array();
|
||||
foreach ( (array) $pages as $p ) {
|
||||
$parent_id = intval( $p->post_parent );
|
||||
$parent_id = (int) $p->post_parent;
|
||||
$children[ $parent_id ][] = $p;
|
||||
}
|
||||
|
||||
@ -5519,7 +5519,7 @@ function get_pages( $args = array() ) {
|
||||
if ( ! empty( $post_authors ) ) {
|
||||
foreach ( $post_authors as $post_author ) {
|
||||
// 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 );
|
||||
if ( empty( $post_author ) ) {
|
||||
continue;
|
||||
|
@ -1320,7 +1320,7 @@ function rest_is_boolean( $maybe_bool ) {
|
||||
* @return bool True if an integer, otherwise false.
|
||||
*/
|
||||
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'] ) {
|
||||
return strval( $value );
|
||||
return (string) $value;
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
@ -499,10 +499,10 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller {
|
||||
if ( $crop ) {
|
||||
$size = $image_editor->get_size();
|
||||
|
||||
$crop_x = round( ( $size['width'] * floatval( $request['x'] ) ) / 100.0 );
|
||||
$crop_y = round( ( $size['height'] * floatval( $request['y'] ) ) / 100.0 );
|
||||
$width = round( ( $size['width'] * floatval( $request['width'] ) ) / 100.0 );
|
||||
$height = round( ( $size['height'] * floatval( $request['height'] ) ) / 100.0 );
|
||||
$crop_x = round( ( $size['width'] * (float) $request['x'] ) / 100.0 );
|
||||
$crop_y = round( ( $size['height'] * (float) $request['y'] ) / 100.0 );
|
||||
$width = round( ( $size['width'] * (float) $request['width'] ) / 100.0 );
|
||||
$height = round( ( $size['height'] * (float) $request['height'] ) / 100.0 );
|
||||
|
||||
$result = $image_editor->crop( $crop_x, $crop_y, $width, $height );
|
||||
|
||||
|
@ -128,10 +128,10 @@ class WP_REST_Block_Directory_Controller extends WP_REST_Controller {
|
||||
'description' => wp_trim_words( $plugin['description'], 30, '...' ),
|
||||
'id' => $plugin['slug'],
|
||||
'rating' => $plugin['rating'] / 20,
|
||||
'rating_count' => intval( $plugin['num_ratings'] ),
|
||||
'active_installs' => intval( $plugin['active_installs'] ),
|
||||
'rating_count' => (int) $plugin['num_ratings'],
|
||||
'active_installs' => (int) $plugin['active_installs'],
|
||||
'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'] ),
|
||||
'icon' => ( isset( $plugin['icons']['1x'] ) ? $plugin['icons']['1x'] : 'block-default' ),
|
||||
'last_updated' => gmdate( 'Y-m-d\TH:i:s', strtotime( $plugin['last_updated'] ) ),
|
||||
|
@ -109,7 +109,7 @@ class WP_REST_Block_Renderer_Controller extends WP_REST_Controller {
|
||||
public function get_item_permissions_check( $request ) {
|
||||
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 ) {
|
||||
$post = get_post( $post_id );
|
||||
@ -149,7 +149,7 @@ class WP_REST_Block_Renderer_Controller extends WP_REST_Controller {
|
||||
public function get_item( $request ) {
|
||||
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 ) {
|
||||
$post = get_post( $post_id );
|
||||
|
@ -547,7 +547,7 @@ function wp_revisions_to_keep( $post ) {
|
||||
if ( true === $num ) {
|
||||
$num = -1;
|
||||
} else {
|
||||
$num = intval( $num );
|
||||
$num = (int) $num;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
$thumbnail_id = intval( $_REQUEST['_thumbnail_id'] );
|
||||
$thumbnail_id = (int) $_REQUEST['_thumbnail_id'];
|
||||
if ( $thumbnail_id <= 0 ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return strval( $thumbnail_id );
|
||||
return (string) $thumbnail_id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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 ( 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.
|
||||
if ( intval( $query_vars['year'] ) !== intval( $matches[1] ) ) {
|
||||
if ( (int) $query_vars['year'] !== (int) $matches[1] ) {
|
||||
return $query_vars;
|
||||
}
|
||||
|
||||
// $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;
|
||||
}
|
||||
}
|
||||
@ -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 ( '' !== $maybe_page ) {
|
||||
$query_vars['page'] = intval( $maybe_page );
|
||||
$query_vars['page'] = (int) $maybe_page;
|
||||
}
|
||||
|
||||
// Next, unset autodetected date-related query vars.
|
||||
|
@ -1048,7 +1048,7 @@ function get_term_children( $term_id, $taxonomy ) {
|
||||
return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
|
||||
}
|
||||
|
||||
$term_id = intval( $term_id );
|
||||
$term_id = (int) $term_id;
|
||||
|
||||
$terms = _get_term_hierarchy( $taxonomy );
|
||||
|
||||
@ -3490,9 +3490,9 @@ function get_object_term_cache( $id, $taxonomy ) {
|
||||
$term_ids = array();
|
||||
foreach ( $_term_ids as $term_id ) {
|
||||
if ( is_numeric( $term_id ) ) {
|
||||
$term_ids[] = intval( $term_id );
|
||||
$term_ids[] = (int) $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 ) ) {
|
||||
$shared_term = $term_id;
|
||||
$term_id = intval( $shared_term->term_id );
|
||||
$term_id = (int) $shared_term->term_id;
|
||||
}
|
||||
|
||||
if ( is_object( $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.
|
||||
@ -4120,7 +4120,7 @@ function _wp_batch_split_terms() {
|
||||
// Rekey shared term array for faster lookups.
|
||||
$_shared_terms = array();
|
||||
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 = $_shared_terms;
|
||||
@ -4134,7 +4134,7 @@ function _wp_batch_split_terms() {
|
||||
$skipped_first_term = array();
|
||||
$taxonomies = array();
|
||||
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.
|
||||
if ( ! isset( $skipped_first_term[ $term_id ] ) ) {
|
||||
|
@ -322,7 +322,7 @@ function wp_update_plugins( $extra_stats = array() ) {
|
||||
foreach ( $plugins as $file => $p ) {
|
||||
$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;
|
||||
}
|
||||
}
|
||||
@ -527,7 +527,7 @@ function wp_update_themes( $extra_stats = array() ) {
|
||||
$theme_changed = false;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ $is_IIS = ! $is_apache && ( strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS'
|
||||
*
|
||||
* @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.)
|
||||
|
@ -109,8 +109,8 @@ class WP_Widget_Links extends WP_Widget {
|
||||
$instance['orderby'] = $new_instance['orderby'];
|
||||
}
|
||||
|
||||
$instance['category'] = intval( $new_instance['category'] );
|
||||
$instance['limit'] = ! empty( $new_instance['limit'] ) ? intval( $new_instance['limit'] ) : -1;
|
||||
$instance['category'] = (int) $new_instance['category'];
|
||||
$instance['limit'] = ! empty( $new_instance['limit'] ) ? (int) $new_instance['limit'] : -1;
|
||||
|
||||
return $instance;
|
||||
}
|
||||
@ -138,7 +138,7 @@ class WP_Widget_Links extends WP_Widget {
|
||||
)
|
||||
);
|
||||
$link_cats = get_terms( array( 'taxonomy' => 'link_category' ) );
|
||||
$limit = intval( $instance['limit'] );
|
||||
$limit = (int) $instance['limit'];
|
||||
if ( ! $limit ) {
|
||||
$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' ); ?>">
|
||||
<option value=""><?php _ex( 'All Links', 'links widget' ); ?></option>
|
||||
<?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 ); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
@ -181,7 +181,7 @@ class WP_Widget_Links extends WP_Widget {
|
||||
|
||||
<p>
|
||||
<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>
|
||||
<?php
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ abstract class WP_Widget_Media extends WP_Widget {
|
||||
class="media-widget-instance-property"
|
||||
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(). ?>"
|
||||
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
|
||||
endforeach;
|
||||
|
@ -46,7 +46,7 @@ $request_array = 'HTTP_POST_VARS';
|
||||
|
||||
if ( ! isset( $_GET['tb_id'] ) || ! $_GET['tb_id'] ) {
|
||||
$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'] : '';
|
||||
@ -84,7 +84,7 @@ if ( is_single() || is_page() ) {
|
||||
$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.' ) );
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ function xml_array_dumbdown( &$data ) {
|
||||
|
||||
function dmp( ...$args ) {
|
||||
foreach ( $args as $thing ) {
|
||||
echo ( is_scalar( $thing ) ? strval( $thing ) : var_export( $thing, true ) ), "\n";
|
||||
echo ( is_scalar( $thing ) ? (string) $thing : var_export( $thing, true ) ), "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -319,7 +319,7 @@ function gen_tests_array( $name, $array ) {
|
||||
$out = array();
|
||||
foreach ( $array as $k => $v ) {
|
||||
if ( is_numeric( $k ) ) {
|
||||
$index = strval( $k );
|
||||
$index = (string) $k;
|
||||
} else {
|
||||
$index = "'" . addcslashes( $k, "\n\r\t'\\" ) . "'";
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
|
||||
$this->assertSame( $user->display_name, $comment->comment_author );
|
||||
$this->assertSame( $user->user_email, $comment->comment_author_email );
|
||||
$this->assertSame( $user->user_url, $comment->comment_author_url );
|
||||
$this->assertSame( $user->ID, intval( $comment->user_id ) );
|
||||
$this->assertSame( $user->ID, (int) $comment->user_id );
|
||||
|
||||
}
|
||||
|
||||
|
@ -2767,7 +2767,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
* @return int Value.
|
||||
*/
|
||||
function sanitize_foo_for_test_set_post_value( $value ) {
|
||||
return intval( $value );
|
||||
return (int) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -173,8 +173,8 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
'type' => 'post_type',
|
||||
'type_label' => 'Post',
|
||||
'object' => 'post',
|
||||
'object_id' => intval( $post_id ),
|
||||
'url' => get_permalink( intval( $post_id ) ),
|
||||
'object_id' => (int) $post_id,
|
||||
'url' => get_permalink( (int) $post_id ),
|
||||
);
|
||||
|
||||
// Offset the query and get the second page of menu items.
|
||||
@ -205,8 +205,8 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
'type' => 'post_type',
|
||||
'type_label' => 'Page',
|
||||
'object' => 'page',
|
||||
'object_id' => intval( $page_id ),
|
||||
'url' => get_permalink( intval( $page_id ) ),
|
||||
'object_id' => (int) $page_id,
|
||||
'url' => get_permalink( (int) $page_id ),
|
||||
);
|
||||
|
||||
$items = $menus->load_available_items_query( 'post_type', 'page', 0 );
|
||||
@ -231,8 +231,8 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
'type' => 'post_type',
|
||||
'type_label' => 'Post',
|
||||
'object' => 'post',
|
||||
'object_id' => intval( $post_id ),
|
||||
'url' => get_permalink( intval( $post_id ) ),
|
||||
'object_id' => (int) $post_id,
|
||||
'url' => get_permalink( (int) $post_id ),
|
||||
);
|
||||
|
||||
$items = $menus->load_available_items_query( 'post_type', 'post', 0 );
|
||||
@ -257,8 +257,8 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
'type' => 'taxonomy',
|
||||
'type_label' => 'Category',
|
||||
'object' => 'category',
|
||||
'object_id' => intval( $term_id ),
|
||||
'url' => get_term_link( intval( $term_id ), 'category' ),
|
||||
'object_id' => (int) $term_id,
|
||||
'url' => get_term_link( (int) $term_id, 'category' ),
|
||||
);
|
||||
|
||||
$items = $menus->load_available_items_query( 'taxonomy', 'category', 0 );
|
||||
@ -327,8 +327,8 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
'type' => 'post_type',
|
||||
'type_label' => get_post_type_object( 'post' )->labels->singular_name,
|
||||
'object' => 'post',
|
||||
'object_id' => intval( $post_id ),
|
||||
'url' => get_permalink( intval( $post_id ) ),
|
||||
'object_id' => (int) $post_id,
|
||||
'url' => get_permalink( (int) $post_id ),
|
||||
);
|
||||
wp_set_object_terms( $post_id, $term_ids, 'category' );
|
||||
$search = $post_id === $post_ids[0] ? 'test & search' : 'other title';
|
||||
@ -351,8 +351,8 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
'type' => 'taxonomy',
|
||||
'type_label' => get_taxonomy( 'category' )->labels->singular_name,
|
||||
'object' => 'category',
|
||||
'object_id' => intval( $term_id ),
|
||||
'url' => get_term_link( intval( $term_id ), 'category' ),
|
||||
'object_id' => (int) $term_id,
|
||||
'url' => get_term_link( (int) $term_id, 'category' ),
|
||||
);
|
||||
$s = sanitize_text_field( wp_unslash( $term->name ) );
|
||||
$results = $menus->search_available_items_query(
|
||||
@ -431,8 +431,8 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
'type' => 'taxonomy',
|
||||
'type_label' => 'Tests Taxonomy',
|
||||
'object' => 'wptests_tax',
|
||||
'object_id' => intval( $term_id ),
|
||||
'url' => get_term_link( intval( $term_id ), '' ),
|
||||
'object_id' => (int) $term_id,
|
||||
'url' => get_term_link( (int) $term_id, '' ),
|
||||
);
|
||||
|
||||
$results = $menus->search_available_items_query(
|
||||
|
@ -66,7 +66,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
|
||||
*/
|
||||
function render_post_content_partial( $partial ) {
|
||||
$id_data = $partial->id_data();
|
||||
$post_id = intval( $id_data['keys'][0] );
|
||||
$post_id = (int) $id_data['keys'][0];
|
||||
if ( empty( $post_id ) ) {
|
||||
return false;
|
||||
}
|
||||
|
@ -482,7 +482,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
|
||||
'id_base' => 'search',
|
||||
'widget-width' => '250',
|
||||
'widget-height' => '200',
|
||||
'widget_number' => strval( $widget_number ),
|
||||
'widget_number' => (string) $widget_number,
|
||||
'multi_number' => '',
|
||||
'add_new' => '',
|
||||
)
|
||||
|
@ -555,7 +555,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase {
|
||||
$data = wp_read_image_metadata( $file );
|
||||
|
||||
// The orientation value 3 is equivalent to rotated upside down (180 degrees).
|
||||
$this->assertSame( 3, intval( $data['orientation'] ), 'Orientation value read from does not match image file Exif data: ' . $file );
|
||||
$this->assertSame( 3, (int) $data['orientation'], 'Orientation value read from does not match image file Exif data: ' . $file );
|
||||
|
||||
$temp_file = wp_tempnam( $file );
|
||||
$image = wp_get_image_editor( $file );
|
||||
@ -567,7 +567,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase {
|
||||
$data = wp_read_image_metadata( $ret['path'] );
|
||||
|
||||
// Make sure the image is no longer in The Upside Down Exif orientation.
|
||||
$this->assertSame( 1, intval( $data['orientation'] ), 'Orientation Exif data was not updated after rotating image: ' . $file );
|
||||
$this->assertSame( 1, (int) $data['orientation'], 'Orientation Exif data was not updated after rotating image: ' . $file );
|
||||
|
||||
// Remove both the generated file ending in .tmp and tmp.jpg due to wp_tempnam().
|
||||
unlink( $temp_file );
|
||||
|
@ -120,7 +120,7 @@ if ( is_multisite() ) :
|
||||
$this->assertTrue( add_blog_option( $blog_id, $key, $value ) );
|
||||
// Assert all values of $blog_id that means the current or main blog (the same here).
|
||||
$this->assertSame( $value, get_blog_option( $blog_id, $key ) );
|
||||
$this->assertSame( $value, get_blog_option( "$blog_id", $key ) );
|
||||
$this->assertSame( $value, get_blog_option( (string) $blog_id, $key ) );
|
||||
// $this->assertSame( $value, get_option( $key ) ); // Check get_option().
|
||||
|
||||
$this->assertFalse( add_blog_option( $blog_id, $key, $value ) ); // Already exists.
|
||||
|
@ -43,7 +43,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
* Helper function: return the timestamp(s) of cron jobs for the specified hook and post.
|
||||
*/
|
||||
function _next_schedule_for_post( $hook, $id ) {
|
||||
return wp_next_scheduled( 'publish_future_post', array( 0 => intval( $id ) ) );
|
||||
return wp_next_scheduled( 'publish_future_post', array( 0 => (int) $id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -483,7 +483,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
|
||||
$this->assertTrue( in_array( $id1, $ids, true ) );
|
||||
$this->assertFalse( in_array( $id2, $ids, true ) );
|
||||
|
||||
$request->set_param( 'exclude', "$id2" );
|
||||
$request->set_param( 'exclude', (string) $id2 );
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$ids = wp_list_pluck( $data, 'id' );
|
||||
|
@ -25,7 +25,7 @@ class Tests_Term_GetTermLink extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$term = intval( $t1 );
|
||||
$term = (int) $t1;
|
||||
|
||||
$actual = get_term_link( $term, 'wptests_tax' );
|
||||
$this->assertContains( 'wptests_tax=foo', $actual );
|
||||
|
@ -15,7 +15,7 @@ class Tests_TermExists extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$found = term_exists( intval( $t ), 'post_tag' );
|
||||
$found = term_exists( (int) $t, 'post_tag' );
|
||||
$this->assertEquals( $t, $found['term_id'] );
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ class Tests_TermExists extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertNull( term_exists( intval( $t ), 'foo' ) );
|
||||
$this->assertNull( term_exists( (int) $t, 'foo' ) );
|
||||
}
|
||||
|
||||
public function test_term_exists_term_int_taxonomy_empty_term_exists() {
|
||||
@ -40,7 +40,7 @@ class Tests_TermExists extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$found = term_exists( intval( $t ), 'post_tag' );
|
||||
$found = term_exists( (int) $t, 'post_tag' );
|
||||
$this->assertEquals( $t, $found['term_id'] );
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ class Tests_Term_WpDeleteTerm extends WP_UnitTestCase {
|
||||
|
||||
wp_delete_term( $terms[0], 'wptests_tax' );
|
||||
$this->assertSame( 1, $this->deleted_term->count );
|
||||
$this->assertSame( $this->object_ids, array( "$post_id" ) );
|
||||
$this->assertSame( $this->object_ids, array( (string) $post_id ) );
|
||||
|
||||
wp_delete_term( $terms[1], 'wptests_tax' );
|
||||
$this->assertSame( 0, $this->deleted_term->count );
|
||||
|
@ -145,7 +145,7 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase {
|
||||
// Remember which term has which term_id.
|
||||
for ( $i = 0; $i < 3; $i++ ) {
|
||||
$term = get_term_by( 'name', $terms[ $i ], $this->taxonomy );
|
||||
$term_id[ $terms[ $i ] ] = intval( $term->term_id );
|
||||
$term_id[ $terms[ $i ] ] = (int) $term->term_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ class Tests_User_GetUsersWithNoRole extends WP_UnitTestCase {
|
||||
$users = wp_get_users_with_no_role();
|
||||
$this->assertSame(
|
||||
array(
|
||||
"{$nobody}",
|
||||
(string) $nobody,
|
||||
),
|
||||
$users
|
||||
);
|
||||
@ -99,7 +99,7 @@ class Tests_User_GetUsersWithNoRole extends WP_UnitTestCase {
|
||||
$users = wp_get_users_with_no_role( $blog_1 );
|
||||
$this->assertSame(
|
||||
array(
|
||||
"{$admin}",
|
||||
(string) $admin,
|
||||
),
|
||||
$users
|
||||
);
|
||||
|
@ -102,7 +102,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase {
|
||||
$this->assertNotIXRError( $results2 );
|
||||
$last_comment_count = 100;
|
||||
foreach ( $results2 as $post ) {
|
||||
$comment_count = intval( get_comments_number( $post['post_id'] ) );
|
||||
$comment_count = (int) get_comments_number( $post['post_id'] );
|
||||
$this->assertLessThanOrEqual( $last_comment_count, $comment_count );
|
||||
$last_comment_count = $comment_count;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user