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:
@@ -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 = '';
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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" />';
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user