Coding Standards: Use pre-increment/decrement for stand-alone statements.

Note: This is enforced by WPCS 3.0.0:

1. There should be no space between an increment/decrement operator and the variable it applies to.
2. Pre-increment/decrement should be favoured over post-increment/decrement for stand-alone statements. “Pre” will in/decrement and then return, “post” will return and then in/decrement. Using the “pre” version is slightly more performant and can prevent future bugs when code gets moved around.

References:
* [https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#increment-decrement-operators WordPress PHP Coding Standards: Increment/decrement operators]
* [https://github.com/WordPress/WordPress-Coding-Standards/pull/2130 WPCS: PR #2130 Core: add sniffs to check formatting of increment/decrement operators]

Props jrf.
See #59161, #58831.
Built from https://develop.svn.wordpress.org/trunk@56549


git-svn-id: http://core.svn.wordpress.org/trunk@56061 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2023-09-09 09:28:26 +00:00
parent d8936a9fe7
commit b80ce60f70
65 changed files with 146 additions and 146 deletions

View File

@ -84,31 +84,31 @@ if ( $doaction ) {
switch ( $doaction ) {
case 'approve':
wp_set_comment_status( $comment_id, 'approve' );
$approved++;
++$approved;
break;
case 'unapprove':
wp_set_comment_status( $comment_id, 'hold' );
$unapproved++;
++$unapproved;
break;
case 'spam':
wp_spam_comment( $comment_id );
$spammed++;
++$spammed;
break;
case 'unspam':
wp_unspam_comment( $comment_id );
$unspammed++;
++$unspammed;
break;
case 'trash':
wp_trash_comment( $comment_id );
$trashed++;
++$trashed;
break;
case 'untrash':
wp_untrash_comment( $comment_id );
$untrashed++;
++$untrashed;
break;
case 'delete':
wp_delete_comment( $comment_id );
$deleted++;
++$deleted;
break;
}
}

View File

@ -124,7 +124,7 @@ if ( $doaction ) {
}
if ( wp_check_post_lock( $post_id ) ) {
$locked++;
++$locked;
continue;
}
@ -132,7 +132,7 @@ if ( $doaction ) {
wp_die( __( 'Error in moving the item to Trash.' ) );
}
$trashed++;
++$trashed;
}
$sendback = add_query_arg(
@ -160,7 +160,7 @@ if ( $doaction ) {
wp_die( __( 'Error in restoring the item from Trash.' ) );
}
$untrashed++;
++$untrashed;
}
$sendback = add_query_arg( 'untrashed', $untrashed, $sendback );
@ -185,7 +185,7 @@ if ( $doaction ) {
wp_die( __( 'Error in deleting the item.' ) );
}
}
$deleted++;
++$deleted;
}
$sendback = add_query_arg( 'deleted', $deleted, $sendback );
break;

View File

@ -2149,7 +2149,7 @@ function wp_ajax_inline_save() {
while ( $parent > 0 ) {
$parent_post = get_post( $parent );
$parent = $parent_post->post_parent;
$level++;
++$level;
}
}
@ -2211,7 +2211,7 @@ function wp_ajax_inline_save_tax() {
while ( $parent > 0 ) {
$parent_tag = get_term( $parent, $taxonomy );
$parent = $parent_tag->parent;
$level++;
++$level;
}
$wp_list_table->single_row( $tag, $level );
@ -2821,7 +2821,7 @@ function wp_ajax_set_attachment_thumbnail() {
}
if ( set_post_thumbnail( $post_id, $thumbnail_id ) ) {
$success++;
++$success;
}
}

View File

@ -238,7 +238,7 @@ class Language_Pack_Upgrader extends WP_Upgrader {
$destination .= '/themes';
}
$this->update_current++;
++$this->update_current;
$options = array(
'package' => $language_update->package,

View File

@ -330,7 +330,7 @@ class Plugin_Upgrader extends WP_Upgrader {
$this->update_count = count( $plugins );
$this->update_current = 0;
foreach ( $plugins as $plugin ) {
$this->update_current++;
++$this->update_current;
$this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true );
if ( ! isset( $current->response[ $plugin ] ) ) {

View File

@ -426,7 +426,7 @@ class Theme_Upgrader extends WP_Upgrader {
$this->update_count = count( $themes );
$this->update_current = 0;
foreach ( $themes as $theme ) {
$this->update_current++;
++$this->update_current;
$this->skin->theme_info = $this->theme_info( $theme );

View File

@ -1390,7 +1390,7 @@ class WP_Automatic_Updater {
} else {
/* translators: %s: WordPress version. */
$body[] = sprintf( __( 'FAILED: WordPress failed to update to %s' ), $result->name );
$failures++;
++$failures;
}
$body[] = '';
@ -1432,7 +1432,7 @@ class WP_Automatic_Updater {
if ( ! $item->result || is_wp_error( $item->result ) ) {
/* translators: %s: Name of plugin / theme / translation. */
$body[] = ' * ' . sprintf( __( 'FAILED: %s' ), $item->name );
$failures++;
++$failures;
}
}
}

View File

@ -1410,7 +1410,7 @@ class WP_List_Table {
'</span>' .
'</label>' .
'<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />';
$cb_counter++;
++$cb_counter;
}
foreach ( $columns as $column_key => $column_display_name ) {

View File

@ -728,7 +728,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
$suffix = 2;
while ( in_array( $plugin_id_attr, $plugin_id_attrs, true ) ) {
$plugin_id_attr = "$plugin_slug-$suffix";
$suffix++;
++$suffix;
}
$plugin_id_attrs[] = $plugin_id_attr;

View File

@ -898,7 +898,7 @@ class WP_Posts_List_Table extends WP_List_Table {
$to_display[ $page->ID ] = $level;
}
$count++;
++$count;
if ( isset( $children_pages ) ) {
$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display );
@ -917,7 +917,7 @@ class WP_Posts_List_Table extends WP_List_Table {
$to_display[ $op->ID ] = 0;
}
$count++;
++$count;
}
}
}
@ -992,7 +992,7 @@ class WP_Posts_List_Table extends WP_List_Table {
while ( $my_parent = array_pop( $my_parents ) ) {
$to_display[ $my_parent->ID ] = $level - $num_parents;
$num_parents--;
--$num_parents;
}
}
@ -1000,7 +1000,7 @@ class WP_Posts_List_Table extends WP_List_Table {
$to_display[ $page->ID ] = $level;
}
$count++;
++$count;
$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display );
}
@ -1097,7 +1097,7 @@ class WP_Posts_List_Table extends WP_List_Table {
break;
}
$this->current_level++;
++$this->current_level;
$find_main_page = (int) $parent->post_parent;
if ( ! isset( $parent_name ) ) {
@ -2085,7 +2085,7 @@ class WP_Posts_List_Table extends WP_List_Table {
</td></tr>
<?php
$bulk++;
++$bulk;
endwhile;
?>
</tbody></table>

View File

@ -239,9 +239,9 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
$resend = _wp_privacy_resend_request( $request_id );
if ( $resend && ! is_wp_error( $resend ) ) {
$count++;
++$count;
} else {
$failures++;
++$failures;
}
}
@ -286,7 +286,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
$result = _wp_privacy_completed_request( $request_id );
if ( $result && ! is_wp_error( $result ) ) {
$count++;
++$count;
}
}
@ -309,9 +309,9 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
case 'delete':
foreach ( $request_ids as $request_id ) {
if ( wp_delete_post( $request_id, true ) ) {
$count++;
++$count;
} else {
$failures++;
++$failures;
}
}

View File

@ -381,14 +381,14 @@ class WP_Site_Health {
// Loop over the available plugins and check their versions and active state.
foreach ( $plugins as $plugin_path => $plugin ) {
$plugins_total++;
++$plugins_total;
if ( is_plugin_active( $plugin_path ) ) {
$plugins_active++;
++$plugins_active;
}
if ( array_key_exists( $plugin_path, $plugin_updates ) ) {
$plugins_need_update++;
++$plugins_need_update;
}
}
@ -543,21 +543,21 @@ class WP_Site_Health {
}
foreach ( $all_themes as $theme_slug => $theme ) {
$themes_total++;
++$themes_total;
if ( array_key_exists( $theme_slug, $theme_updates ) ) {
$themes_need_updates++;
++$themes_need_updates;
}
}
// If this is a child theme, increase the allowed theme count by one, to account for the parent.
if ( is_child_theme() ) {
$allowed_theme_count++;
++$allowed_theme_count;
}
// If there's a default theme installed and not in use, we count that as allowed as well.
if ( $has_default_theme && ! $using_default_theme ) {
$allowed_theme_count++;
++$allowed_theme_count;
}
if ( $themes_total > $allowed_theme_count ) {
@ -3293,11 +3293,11 @@ class WP_Site_Health {
foreach ( $results as $result ) {
if ( 'critical' === $result['status'] ) {
$site_status['critical']++;
++$site_status['critical'];
} elseif ( 'recommended' === $result['status'] ) {
$site_status['recommended']++;
++$site_status['recommended'];
} else {
$site_status['good']++;
++$site_status['good'];
}
}

View File

@ -310,7 +310,7 @@ class WP_Terms_List_Table extends WP_List_Table {
while ( $my_parent = array_pop( $my_parents ) ) {
echo "\t";
$this->single_row( $my_parent, $level - $num_parents );
$num_parents--;
--$num_parents;
}
}

View File

@ -1493,7 +1493,7 @@ function verify_file_signature( $filename, $signatures, $filename_for_errors = f
// Ensure only valid-length signatures are considered.
if ( SODIUM_CRYPTO_SIGN_BYTES !== strlen( $signature_raw ) ) {
$skipped_signature++;
++$skipped_signature;
continue;
}
@ -1502,7 +1502,7 @@ function verify_file_signature( $filename, $signatures, $filename_for_errors = f
// Only pass valid public keys through.
if ( SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES !== strlen( $key_raw ) ) {
$skipped_key++;
++$skipped_key;
continue;
}

View File

@ -979,7 +979,7 @@ function wp_save_image( $post_id ) {
$new_path = "{$dirname}/$new_filename";
if ( file_exists( $new_path ) ) {
$suffix++;
++$suffix;
} else {
break;
}

View File

@ -638,7 +638,7 @@ function wp_iframe( $content_func, ...$args ) {
*/
function media_buttons( $editor_id = 'content' ) {
static $instance = 0;
$instance++;
++$instance;
$post = get_post();

View File

@ -228,7 +228,7 @@ function add_menu_classes( $menu ) {
$i = 0;
foreach ( $menu as $order => $top ) {
$i++;
++$i;
if ( 0 === $order ) { // Dashboard is always shown/single.
$menu[0][4] = add_cssclass( 'menu-top-first', $top[4] );

View File

@ -403,7 +403,7 @@ function wp_print_theme_file_tree( $tree, $level = 2, $size = 1, $index = 1 ) {
$size = count( $tree );
foreach ( $tree as $label => $theme_file ) :
$index++;
++$index;
if ( ! is_array( $theme_file ) ) {
wp_print_theme_file_tree( $theme_file, $level, $index, $size );
@ -505,7 +505,7 @@ function wp_print_plugin_file_tree( $tree, $label = '', $level = 2, $size = 1, $
$size = count( $tree );
foreach ( $tree as $label => $plugin_file ) :
$index++;
++$index;
if ( ! is_array( $plugin_file ) ) {
wp_print_plugin_file_tree( $plugin_file, $label, $level, $index, $size );

View File

@ -734,7 +734,7 @@ function avoid_blog_page_permalink_collision( $data, $postarr ) {
while ( $c < 10 && get_id_from_blogname( $post_name ) ) {
$post_name .= mt_rand( 1, 10 );
$c++;
++$c;
}
if ( $post_name !== $data['post_name'] ) {

View File

@ -1355,7 +1355,7 @@ function do_meta_boxes( $screen, $context, $data_object ) {
}
}
$i++;
++$i;
// get_hidden_meta_boxes() doesn't apply in the block editor.
$hidden_class = ( ! $screen->is_block_editor() && in_array( $box['id'], $hidden, true ) ) ? ' hide-if-js' : '';
echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes( $box['id'], $page ) . $hidden_class . '" ' . '>' . "\n";
@ -1550,7 +1550,7 @@ function do_accordion_sections( $screen, $context, $data_object ) {
continue;
}
$i++;
++$i;
$hidden_class = in_array( $box['id'], $hidden, true ) ? 'hide-if-js' : '';
$open_class = '';

View File

@ -1292,7 +1292,7 @@ function upgrade_230() {
$num = 2;
do {
$alt_slug = $slug . "-$num";
$num++;
++$num;
$slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug ) );
} while ( $slug_check );

View File

@ -134,7 +134,7 @@ function wp_list_widget_controls( $sidebar, $sidebar_name = '' ) {
function wp_list_widget_controls_dynamic_sidebar( $params ) {
global $wp_registered_widgets;
static $i = 0;
$i++;
++$i;
$widget_id = $params[0]['widget_id'];
$id = isset( $params[0]['_temp_id'] ) ? $params[0]['_temp_id'] : $widget_id;
@ -168,7 +168,7 @@ function next_widget_id_number( $id_base ) {
$number = max( $number, $matches[1] );
}
}
$number++;
++$number;
return $number;
}

View File

@ -45,7 +45,7 @@ switch ( $action ) {
$link_id = (int) $link_id;
if ( wp_delete_link( $link_id ) ) {
$deleted++;
++$deleted;
}
}

View File

@ -161,7 +161,7 @@ foreach ( array_merge( $builtin, $types ) as $ptype ) {
*/
$core_menu_positions = array( 59, 60, 65, 70, 75, 80, 85, 99 );
while ( isset( $menu[ $ptype_menu_position ] ) || in_array( $ptype_menu_position, $core_menu_positions, true ) ) {
$ptype_menu_position++;
++$ptype_menu_position;
}
$menu[ $ptype_menu_position ] = array( esc_attr( $ptype_obj->labels->menu_name ), $ptype_obj->cap->edit_posts, $ptype_file, '', $menu_class, $ptype_menu_id, $menu_icon );

View File

@ -184,7 +184,7 @@ if ( isset( $_GET['action'] ) ) {
continue;
}
wpmu_delete_user( $id );
$i++;
++$i;
}
}

View File

@ -381,7 +381,7 @@ switch ( $wp_list_table->current_action() ) {
);
echo "</li>\n";
$go_delete++;
++$go_delete;
}
}
?>

View File

@ -310,7 +310,7 @@ if ( isset( $_GET['editwidget'] ) && $_GET['editwidget'] ) {
} else {
$j = count( $sidebars_widgets[ $sbname ] );
if ( isset( $_GET['addnew'] ) || ! in_array( $widget_id, $sidebars_widgets[ $sbname ], true ) ) {
$j++;
++$j;
}
}
$selected = '';
@ -540,7 +540,7 @@ foreach ( $theme_sidebars as $sidebar => $registered_sidebar ) {
</div>
<?php
$i++;
++$i;
}
?>

View File

@ -667,15 +667,15 @@ function twentyeleven_footer_sidebar_class() {
$count = 0;
if ( is_active_sidebar( 'sidebar-3' ) ) {
$count++;
++$count;
}
if ( is_active_sidebar( 'sidebar-4' ) ) {
$count++;
++$count;
}
if ( is_active_sidebar( 'sidebar-5' ) ) {
$count++;
++$count;
}
$class = '';

View File

@ -77,7 +77,7 @@ get_header(); ?>
// If there is more than 1 attachment in a gallery...
if ( count( $attachments ) > 1 ) {
$k++;
++$k;
if ( isset( $attachments[ $k ] ) ) {
// ...get the URL of the next image attachment.
$next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );

View File

@ -88,7 +88,7 @@ get_header(); ?>
$featured->the_post();
// Increase the counter.
$counter_slider++;
++$counter_slider;
/*
* We're going to add a class to our featured post for featured images.
@ -153,7 +153,7 @@ get_header(); ?>
// Let's roll again.
while ( $featured->have_posts() ) :
$featured->the_post();
$counter_slider++;
++$counter_slider;
if ( 1 === $counter_slider ) {
$class = ' class="active"';
} else {

View File

@ -89,7 +89,7 @@ function twentyseventeen_panel_count() {
// Create a setting and control for each of the sections available in the theme.
for ( $i = 1; $i < ( 1 + $num_sections ); $i++ ) {
if ( get_theme_mod( 'panel_' . $i ) ) {
$panel_count++;
++$panel_count;
}
}

View File

@ -107,7 +107,7 @@ if ( have_posts() ) {
// If there is more than 1 image attachment in a gallery...
if ( count( $attachments ) > 1 ) {
$k++;
++$k;
if ( isset( $attachments[ $k ] ) ) {
// ...get the URL of the next image attachment.
$next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );

View File

@ -77,7 +77,7 @@ get_header(); ?>
// If there is more than 1 attachment in a gallery...
if ( count( $attachments ) > 1 ) :
$k++;
++$k;
if ( isset( $attachments[ $k ] ) ) :
// ...get the URL of the next image attachment.
$next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );

View File

@ -84,7 +84,7 @@ get_header();
$i = 0;
while ( have_posts() ) {
$i++;
++$i;
if ( $i > 1 ) {
echo '<hr class="post-separator styled-separator is-style-wide section-inner" aria-hidden="true" />';
}

View File

@ -384,7 +384,7 @@ function twenty_twenty_one_print_first_instance_of_block( $block_name, $content
if ( $is_matching_block ) {
// Increment count.
$instances_count++;
++$instances_count;
// Add the block HTML.
$blocks_content .= render_block( $block );

View File

@ -174,7 +174,7 @@ class Walker_Comment extends Walker {
// Restores the more descriptive, specific name for use within this method.
$comment = $data_object;
$depth++;
++$depth;
$GLOBALS['comment_depth'] = $depth;
$GLOBALS['comment'] = $comment;

View File

@ -244,7 +244,7 @@ class WP_Block {
$block_content .= $inner_block->render();
}
$index++;
++$index;
}
}
}

View File

@ -1079,7 +1079,7 @@ class WP_Comment_Query {
wp_cache_set_multiple( $data, 'comment-queries' );
}
$level++;
++$level;
$levels[ $level ] = $child_ids;
} while ( $child_ids );

View File

@ -1077,7 +1077,7 @@ final class WP_Customize_Manager {
continue;
}
if ( update_post_meta( $autosave_autodraft_post->ID, '_customize_restore_dismissed', true ) ) {
$dismissed++;
++$dismissed;
}
}
return $dismissed;
@ -1479,7 +1479,7 @@ final class WP_Customize_Manager {
if ( ! $nav_menu_term_id ) {
while ( isset( $changeset_data[ sprintf( 'nav_menu[%d]', $placeholder_id ) ] ) ) {
$placeholder_id--;
--$placeholder_id;
}
$nav_menu_term_id = $placeholder_id;
$nav_menu_setting_id = sprintf( 'nav_menu[%d]', $placeholder_id );

View File

@ -317,7 +317,7 @@ final class WP_Hook implements Iterator, ArrayAccess {
unset( $this->iterations[ $nesting_level ] );
unset( $this->current_priority[ $nesting_level ] );
$this->nesting_level--;
--$this->nesting_level;
return $value;
}
@ -359,7 +359,7 @@ final class WP_Hook implements Iterator, ArrayAccess {
} while ( false !== next( $this->iterations[ $nesting_level ] ) );
unset( $this->iterations[ $nesting_level ] );
$this->nesting_level--;
--$this->nesting_level;
}
/**

View File

@ -117,12 +117,12 @@ class WP_List_Util {
if ( is_array( $obj ) ) {
// Treat object as an array.
if ( array_key_exists( $m_key, $obj ) && ( $m_value == $obj[ $m_key ] ) ) {
$matched++;
++$matched;
}
} elseif ( is_object( $obj ) ) {
// Treat object as an object.
if ( isset( $obj->{$m_key} ) && ( $m_value == $obj->{$m_key} ) ) {
$matched++;
++$matched;
}
}
}

View File

@ -633,7 +633,7 @@ class WP_Meta_Query {
$clause_key_base = $clause_key;
while ( isset( $this->clauses[ $clause_key ] ) ) {
$clause_key = $clause_key_base . '-' . $iterator;
$iterator++;
++$iterator;
}
// Store the clause in our flat array.

View File

@ -3470,7 +3470,7 @@ class WP_Query {
// Move to front, after other stickies.
array_splice( $this->posts, $sticky_offset, 0, array( $sticky_post ) );
// Increment the sticky offset. The next sticky will be placed at this offset.
$sticky_offset++;
++$sticky_offset;
// Remove post from sticky posts array.
$offset = array_search( $sticky_post->ID, $sticky_posts, true );
unset( $sticky_posts[ $offset ] );
@ -3500,7 +3500,7 @@ class WP_Query {
foreach ( $stickies as $sticky_post ) {
array_splice( $this->posts, $sticky_offset, 0, array( $sticky_post ) );
$sticky_offset++;
++$sticky_offset;
}
}
}
@ -3620,7 +3620,7 @@ class WP_Query {
*/
public function next_post() {
$this->current_post++;
++$this->current_post;
/** @var WP_Post */
$this->post = $this->posts[ $this->current_post ];
@ -3730,7 +3730,7 @@ class WP_Query {
* @return WP_Comment Comment object.
*/
public function next_comment() {
$this->current_comment++;
++$this->current_comment;
/** @var WP_Comment */
$this->comment = $this->comments[ $this->current_comment ];

View File

@ -531,7 +531,7 @@ class WP_Rewrite {
$front = $front . 'date/';
break;
}
$tok_index++;
++$tok_index;
}
$this->date_structure = $front . $date_endian;

View File

@ -3399,7 +3399,7 @@ class WP_Theme_JSON {
}
if ( $below_midpoint_count < $steps_mid_point - 2 ) {
$x_small_count++;
++$x_small_count;
}
$slug -= 10;
@ -3436,7 +3436,7 @@ class WP_Theme_JSON {
}
if ( $above_midpoint_count > 1 ) {
$x_large_count++;
++$x_large_count;
}
$slug += 10;

View File

@ -325,7 +325,7 @@ class Walker {
$empty_array = array();
foreach ( $elements as $e ) {
$count++;
++$count;
if ( $count < $start ) {
continue;
}
@ -372,7 +372,7 @@ class Walker {
}
foreach ( $top_level_elements as $e ) {
$count++;
++$count;
// For the last page, need to unset earlier children in order to keep track of orphans.
if ( $end >= $total_top && $count < $start ) {
@ -416,7 +416,7 @@ class Walker {
foreach ( $elements as $e ) {
if ( empty( $e->$parent_field ) ) {
$num++;
++$num;
}
}
return $num;

View File

@ -1539,7 +1539,7 @@ class wpdb {
$k = 1;
$l = strlen( $s );
while ( $k <= $l && '%' === $s[ $l - $k ] ) {
$k++;
++$k;
}
$placeholder = '%' . ( $k % 2 ? '%' : '' ) . $format . $type;
@ -1600,7 +1600,7 @@ class wpdb {
$new_query .= $split_query[ $key - 2 ] . $split_query[ $key - 1 ] . $placeholder;
$key += 3;
$arg_id++;
++$arg_id;
}
// Replace $query; and add remaining $query characters, or index 0 if there were no placeholders.
@ -1632,7 +1632,7 @@ class wpdb {
$used_placeholders[ $arg_pos ][] = $placeholder;
$key += 3;
$arg_id++;
++$arg_id;
}
$conflicts = array();
@ -2304,7 +2304,7 @@ class wpdb {
if ( $this->result instanceof mysqli_result ) {
while ( $row = mysqli_fetch_object( $this->result ) ) {
$this->last_result[ $num_rows ] = $row;
$num_rows++;
++$num_rows;
}
}
@ -2334,7 +2334,7 @@ class wpdb {
$this->result = mysqli_query( $this->dbh, $query );
}
$this->num_queries++;
++$this->num_queries;
if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) {
$this->log_query(
@ -3878,7 +3878,7 @@ class wpdb {
$new_array = array();
foreach ( (array) $this->col_info as $col ) {
$new_array[ $i ] = $col->{$info_type};
$i++;
++$i;
}
return $new_array;
} else {

View File

@ -549,7 +549,7 @@ function get_comment_class( $css_class = '', $comment_id = null, $post = null )
$classes[] = 'even';
}
$comment_alt++;
++$comment_alt;
// Alt for top-level comments.
if ( 1 == $comment_depth ) {
@ -559,7 +559,7 @@ function get_comment_class( $css_class = '', $comment_id = null, $post = null )
} else {
$classes[] = 'thread-even';
}
$comment_thread_alt++;
++$comment_thread_alt;
}
$classes[] = "depth-$comment_depth";

View File

@ -203,7 +203,7 @@ function _mb_strlen( $str, $encoding = null ) {
do {
// We had some string left over from the last round, but we counted it in that last round.
$count--;
--$count;
/*
* Split by UTF-8 character, limit to 1000 characters (last array element will contain

View File

@ -476,7 +476,7 @@ function wpautop( $text, $br = true ) {
$pre_tags[ $name ] = substr( $text_part, $start ) . '</pre>';
$text .= substr( $text_part, 0, $start ) . $name;
$i++;
++$i;
}
$text .= $last_part;
@ -2657,14 +2657,14 @@ function force_balance_tags( $text ) {
} elseif ( $tagstack[ $stacksize - 1 ] === $tag ) { // Found closing tag.
$tag = '</' . $tag . '>'; // Close tag.
array_pop( $tagstack );
$stacksize--;
--$stacksize;
} else { // Closing tag not at top, search for it.
for ( $j = $stacksize - 1; $j >= 0; $j-- ) {
if ( $tagstack[ $j ] === $tag ) {
// Add tag to tagqueue.
for ( $k = $stacksize - 1; $k >= $j; $k-- ) {
$tagqueue .= '</' . array_pop( $tagstack ) . '>';
$stacksize--;
--$stacksize;
}
break;
}
@ -2692,7 +2692,7 @@ function force_balance_tags( $text ) {
*/
if ( $stacksize > 0 && ! in_array( $tag, $nestable_tags, true ) && $tagstack[ $stacksize - 1 ] === $tag ) {
$tagqueue = '</' . array_pop( $tagstack ) . '>';
$stacksize--;
--$stacksize;
}
$stacksize = array_push( $tagstack, $tag );
}
@ -3083,7 +3083,7 @@ function make_clickable( $text ) {
|| preg_match( '|^<script[\s>]|i', $piece )
|| preg_match( '|^<style[\s>]|i', $piece )
) {
$nested_code_pre++;
++$nested_code_pre;
} elseif ( $nested_code_pre
&& ( '</code>' === strtolower( $piece )
|| '</pre>' === strtolower( $piece )
@ -3091,7 +3091,7 @@ function make_clickable( $text ) {
|| '</style>' === strtolower( $piece )
)
) {
$nested_code_pre--;
--$nested_code_pre;
}
if ( $nested_code_pre
@ -5354,7 +5354,7 @@ function wp_sprintf_l( $pattern, $args ) {
$i = count( $args );
while ( $i ) {
$arg = array_shift( $args );
$i--;
--$i;
if ( 0 === $i ) {
$result .= $l['between_last_two'] . $arg;
} else {

View File

@ -2696,7 +2696,7 @@ function wp_unique_filename( $dir, $filename, $unique_filename_callback = null )
);
$number = $new_number;
$i++;
++$i;
}
}
}
@ -2769,7 +2769,7 @@ function wp_unique_filename( $dir, $filename, $unique_filename_callback = null )
);
$number = $new_number;
$i++;
++$i;
}
}
}
@ -7163,7 +7163,7 @@ function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pr
$trace = debug_backtrace( false );
$caller = array();
$check_class = ! is_null( $ignore_class );
$skip_frames++; // Skip this function.
++$skip_frames; // Skip this function.
if ( ! isset( $truncate_paths ) ) {
$truncate_paths = array(
@ -7174,7 +7174,7 @@ function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pr
foreach ( $trace as $call ) {
if ( $skip_frames > 0 ) {
$skip_frames--;
--$skip_frames;
} elseif ( isset( $call['class'] ) ) {
if ( $check_class && $ignore_class === $call['class'] ) {
continue; // Filter out calls.

View File

@ -951,7 +951,7 @@ class WP_HTML_Tag_Processor {
if ( '/' === $this->html[ $at + 1 ] ) {
$this->is_closing_tag = true;
$at++;
++$at;
} else {
$this->is_closing_tag = false;
}
@ -1020,7 +1020,7 @@ class WP_HTML_Tag_Processor {
*
* See https://html.spec.whatwg.org/#parse-error-incorrectly-closed-comment
*/
$closer_at--; // Pre-increment inside condition below reduces risk of accidental infinite looping.
--$closer_at; // Pre-increment inside condition below reduces risk of accidental infinite looping.
while ( ++$closer_at < strlen( $html ) ) {
$closer_at = strpos( $html, '--', $closer_at );
if ( false === $closer_at ) {
@ -1101,7 +1101,7 @@ class WP_HTML_Tag_Processor {
* See https://html.spec.whatwg.org/#parse-error-missing-end-tag-name
*/
if ( '>' === $html[ $at + 1 ] ) {
$at++;
++$at;
continue;
}

View File

@ -2552,7 +2552,7 @@ function gallery_shortcode( $attr ) {
$post = get_post();
static $instance = 0;
$instance++;
++$instance;
if ( ! empty( $attr['ids'] ) ) {
// 'ids' is explicitly ordered, unless you specify otherwise.
@ -2899,7 +2899,7 @@ function wp_playlist_shortcode( $attr ) {
$post = get_post();
static $instance = 0;
$instance++;
++$instance;
if ( ! empty( $attr['ids'] ) ) {
// 'ids' is explicitly ordered, unless you specify otherwise.
@ -3213,7 +3213,7 @@ function wp_audio_shortcode( $attr, $content = '' ) {
$post_id = get_post() ? get_the_ID() : 0;
static $instance = 0;
$instance++;
++$instance;
/**
* Filters the default audio shortcode output.
@ -3432,7 +3432,7 @@ function wp_video_shortcode( $attr, $content = '' ) {
$post_id = get_post() ? get_the_ID() : 0;
static $instance = 0;
$instance++;
++$instance;
/**
* Filters the default video shortcode output.

View File

@ -877,7 +877,7 @@ function wp_uninitialize_site( $site_id ) {
}
@closedir( $dh );
}
$index++;
++$index;
}
$stack = array_reverse( $stack ); // Last added directories are deepest.

View File

@ -129,7 +129,7 @@ if ( ! class_exists( 'MO', false ) ) :
// Headers' msgid is an empty string.
fwrite( $fh, pack( 'VV', 0, $current_addr ) );
$current_addr++;
++$current_addr;
$originals_table = "\0";
$reader = new POMO_Reader();

View File

@ -110,19 +110,19 @@ if ( ! class_exists( 'Plural_Forms', false ) ) :
// Ignore whitespace.
case ' ':
case "\t":
$pos++;
++$pos;
break;
// Variable (n).
case 'n':
$output[] = array( 'var' );
$pos++;
++$pos;
break;
// Parentheses.
case '(':
$stack[] = $next;
$pos++;
++$pos;
break;
case ')':
@ -144,7 +144,7 @@ if ( ! class_exists( 'Plural_Forms', false ) ) :
throw new Exception( 'Mismatched parentheses' );
}
$pos++;
++$pos;
break;
// Operators.
@ -189,7 +189,7 @@ if ( ! class_exists( 'Plural_Forms', false ) ) :
$o2 = $stack[ $s_pos ];
if ( '?' !== $o2 ) {
$output[] = array( 'op', array_pop( $stack ) );
$s_pos--;
--$s_pos;
continue;
}
@ -202,7 +202,7 @@ if ( ! class_exists( 'Plural_Forms', false ) ) :
if ( ! $found ) {
throw new Exception( 'Missing starting "?" ternary operator' );
}
$pos++;
++$pos;
break;
// Default - number or invalid.
@ -264,7 +264,7 @@ if ( ! class_exists( 'Plural_Forms', false ) ) :
$total = count( $this->tokens );
while ( $i < $total ) {
$next = $this->tokens[ $i ];
$i++;
++$i;
if ( 'var' === $next[0] ) {
$stack[] = $n;
continue;

View File

@ -342,7 +342,7 @@ if ( ! class_exists( 'PO', false ) ) :
$context = '';
$msgstr_index = 0;
while ( true ) {
$lineno++;
++$lineno;
$line = PO::read_line( $f );
if ( ! $line ) {
if ( feof( $f ) ) {
@ -365,7 +365,7 @@ if ( ! class_exists( 'PO', false ) ) :
// The comment is the start of a new entry.
if ( self::is_final( $context ) ) {
PO::read_line( $f, 'put-back' );
$lineno--;
--$lineno;
break;
}
// Comments have to be at the beginning.
@ -377,7 +377,7 @@ if ( ! class_exists( 'PO', false ) ) :
} elseif ( preg_match( '/^msgctxt\s+(".*")/', $line, $m ) ) {
if ( self::is_final( $context ) ) {
PO::read_line( $f, 'put-back' );
$lineno--;
--$lineno;
break;
}
if ( $context && 'comment' !== $context ) {
@ -388,7 +388,7 @@ if ( ! class_exists( 'PO', false ) ) :
} elseif ( preg_match( '/^msgid\s+(".*")/', $line, $m ) ) {
if ( self::is_final( $context ) ) {
PO::read_line( $f, 'put-back' );
$lineno--;
--$lineno;
break;
}
if ( $context && 'msgctxt' !== $context && 'comment' !== $context ) {

View File

@ -261,7 +261,7 @@ if ( ! class_exists( 'Translations', false ) ) :
switch ( $char ) {
case '?':
$res .= ' ? (';
$depth++;
++$depth;
break;
case ':':
$res .= ') : (';

View File

@ -5073,7 +5073,7 @@ function wp_unique_post_slug( $slug, $post_id, $post_status, $post_type, $post_p
do {
$alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_id ) );
$suffix++;
++$suffix;
} while ( $post_name_check );
$slug = $alt_post_name;
}
@ -5110,7 +5110,7 @@ function wp_unique_post_slug( $slug, $post_id, $post_status, $post_type, $post_p
do {
$alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_id, $post_parent ) );
$suffix++;
++$suffix;
} while ( $post_name_check );
$slug = $alt_post_name;
}
@ -5166,7 +5166,7 @@ function wp_unique_post_slug( $slug, $post_id, $post_status, $post_type, $post_p
do {
$alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_id ) );
$suffix++;
++$suffix;
} while ( $post_name_check );
$slug = $alt_post_name;
}
@ -5758,7 +5758,7 @@ function get_page_by_path( $page_path, $output = OBJECT, $post_type = 'page' ) {
* ensuring each matches the post ancestry.
*/
while ( 0 != $p->post_parent && isset( $pages[ $p->post_parent ] ) ) {
$count++;
++$count;
$parent = $pages[ $p->post_parent ];
if ( ! isset( $revparts[ $count ] ) || $parent->post_name != $revparts[ $count ] ) {
break;

View File

@ -3090,7 +3090,7 @@ function wp_unique_term_slug( $slug, $term ) {
$num = 2;
do {
$alt_slug = $slug . "-$num";
$num++;
++$num;
$slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug ) );
} while ( $slug_check );
$slug = $alt_slug;

View File

@ -90,7 +90,7 @@ function wp_filter_wp_template_unique_post_slug( $override_slug, $slug, $post_id
$alt_post_name = _truncate_post_slug( $override_slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
$query_args['post_name__in'] = array( $alt_post_name );
$query = new WP_Query( $query_args );
$suffix++;
++$suffix;
} while ( count( $query->posts ) > 0 );
$override_slug = $alt_post_name;
}

View File

@ -1316,11 +1316,11 @@ function count_users( $strategy = 'time', $site_id = null ) {
continue;
}
if ( empty( $b_roles ) ) {
$avail_roles['none']++;
++$avail_roles['none'];
}
foreach ( $b_roles as $b_role => $val ) {
if ( isset( $avail_roles[ $b_role ] ) ) {
$avail_roles[ $b_role ]++;
++$avail_roles[ $b_role ];
} else {
$avail_roles[ $b_role ] = 1;
}
@ -2177,7 +2177,7 @@ function wp_insert_user( $userdata ) {
$base_length = 49 - mb_strlen( $suffix );
$alt_user_nicename = mb_substr( $user_nicename, 0, $base_length ) . "-$suffix";
$user_nicename_check = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1", $alt_user_nicename, $user_login ) );
$suffix++;
++$suffix;
}
$user_nicename = $alt_user_nicename;
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.4-alpha-56548';
$wp_version = '6.4-alpha-56549';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -66,7 +66,7 @@ class WP_Widget_Calendar extends WP_Widget {
echo '</div>';
echo $args['after_widget'];
self::$instance++;
++self::$instance;
}
/**

View File

@ -373,7 +373,7 @@ abstract class WP_Widget_Media extends WP_Widget {
$use_count = 0;
foreach ( $this->get_settings() as $instance ) {
if ( isset( $instance['attachment_id'] ) && $instance['attachment_id'] === $post->ID ) {
$use_count++;
++$use_count;
}
}