From 384eda933ab24b123ff028f73662cb9455cf901e Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 23 Jul 2026 14:32:52 +0200 Subject: [PATCH] Fix PHP code style violations in feature files --- features/comment-recount.feature | 2 +- features/option-pluck-patch.feature | 4 +- features/post-block.feature | 27 +++++++----- features/post-meta.feature | 2 +- features/taxonomy.feature | 64 ++++++++++++++--------------- features/term-migrate.feature | 12 +++--- features/term-recount.feature | 4 +- features/user-term.feature | 16 +++----- 8 files changed, 67 insertions(+), 64 deletions(-) diff --git a/features/comment-recount.feature b/features/comment-recount.feature index c9216150f..af8737159 100644 --- a/features/comment-recount.feature +++ b/features/comment-recount.feature @@ -15,7 +15,7 @@ Feature: Recount comments on a post """ update( $wpdb->posts, array( "comment_count" => 1 ), array( "ID" => 1 ) ); + $wpdb->update( $wpdb->posts, array( 'comment_count' => 1 ), array( 'ID' => 1 ) ); clean_post_cache( 1 ); """ When I run `wp eval-file recount-comments.php` diff --git a/features/option-pluck-patch.feature b/features/option-pluck-patch.feature index 05b9c4026..1bf36bbd7 100644 --- a/features/option-pluck-patch.feature +++ b/features/option-pluck-patch.feature @@ -276,9 +276,9 @@ Feature: Option commands have pluck and patch. And a setup.php file: """ test_mode = 0; - $ret = update_option( 'wp_cli_test', $option ); + $ret = update_option( 'wp_cli_test', $option ); """ And I run `wp eval-file setup.php` diff --git a/features/post-block.feature b/features/post-block.feature index fa3345c1e..cf2ff2301 100644 --- a/features/post-block.feature +++ b/features/post-block.feature @@ -565,17 +565,22 @@ Feature: Manage blocks in post content And a custom-sync-filter.php file: """ ]*)>/', - '

', - $block['innerHTML'] - ); - $block['innerContent'] = [ $block['innerHTML'] ]; - } - return $block; - }, 10, 3 ); + WP_CLI::add_wp_hook( + 'wp_cli_post_block_update_html', + function ( $block, $new_attrs, $block_name ) { + if ( 'core/paragraph' === $block_name && isset( $new_attrs['customClass'] ) ) { + $block['innerHTML'] = preg_replace( + '/]*)>/', + '

', + $block['innerHTML'] + ); + $block['innerContent'] = [ $block['innerHTML'] ]; + } + return $block; + }, + 10, + 3 + ); """ When I run `wp post create --post_title="Block Post" --post_content="

Hello World

" --porcelain` Then save STDOUT as {POST_ID} diff --git a/features/post-meta.feature b/features/post-meta.feature index 309cf47f7..80302a28b 100644 --- a/features/post-meta.feature +++ b/features/post-meta.feature @@ -182,7 +182,7 @@ Feature: Manage post custom fields And a setup.php file: """ true, - 'show_ui' => true, - 'show_admin_column' => true, - 'update_count_callback' => '_update_post_term_count', - 'query_var' => true, - 'labels' => array( - 'name' => _x( 'Genres', 'taxonomy general name', 'textdomain' ), - ), - - ); - - register_taxonomy( 'genres', array( 'post','page' ), $args ); - } ); + add_action( + 'init', + function () { + $args = array( + 'hierarchical' => true, + 'show_ui' => true, + 'show_admin_column' => true, + 'update_count_callback' => '_update_post_term_count', + 'query_var' => true, + 'labels' => array( + 'name' => _x( 'Genres', 'taxonomy general name', 'textdomain' ), + ), + ); + register_taxonomy( 'genres', array( 'post', 'page' ), $args ); + } + ); """ When I run `wp taxonomy list --object_type=post --strict` @@ -94,22 +94,22 @@ Feature: Manage WordPress taxonomies """ true, - 'show_ui' => true, - 'show_admin_column' => true, - 'update_count_callback' => '_update_post_term_count', - 'query_var' => true, - 'labels' => array( - 'name' => _x( 'Genres', 'taxonomy general name', 'textdomain' ), - ), - - ); - - register_taxonomy( 'genres', array( 'post','page' ), $args ); - } ); + add_action( + 'init', + function () { + $args = array( + 'hierarchical' => true, + 'show_ui' => true, + 'show_admin_column' => true, + 'update_count_callback' => '_update_post_term_count', + 'query_var' => true, + 'labels' => array( + 'name' => _x( 'Genres', 'taxonomy general name', 'textdomain' ), + ), + ); + register_taxonomy( 'genres', array( 'post', 'page' ), $args ); + } + ); """ When I run `wp taxonomy list --object_type=post --strict` diff --git a/features/term-migrate.feature b/features/term-migrate.feature index ea797c371..0234d4b9b 100644 --- a/features/term-migrate.feature +++ b/features/term-migrate.feature @@ -95,11 +95,13 @@ Feature: Migrate term custom fields """ true ] ); - register_taxonomy( 'topic', 'news', [ 'public' => true ] ); - } ); + add_action( + 'init', + function () { + register_post_type( 'news', [ 'public' => true ] ); + register_taxonomy( 'topic', 'news', [ 'public' => true ] ); + } + ); """ When I run `wp term create category grape` diff --git a/features/term-recount.feature b/features/term-recount.feature index ca2edccf2..d11bb78b6 100644 --- a/features/term-recount.feature +++ b/features/term-recount.feature @@ -44,8 +44,8 @@ Feature: Recount terms on a taxonomy """ update( $wpdb->term_taxonomy, array( "count" => 3 ), array( "term_id" => {TERM_ID} ) ); - clean_term_cache( {TERM_ID}, "category" ); + $wpdb->update( $wpdb->term_taxonomy, array( 'count' => 3 ), array( 'term_id' => {TERM_ID} ) ); + clean_term_cache( {TERM_ID}, 'category' ); """ When I run `wp eval-file recount-terms.php` And I run `wp term get category {TERM_ID} --field=count` diff --git a/features/user-term.feature b/features/user-term.feature index 36bafe642..e476e91bc 100644 --- a/features/user-term.feature +++ b/features/user-term.feature @@ -6,12 +6,10 @@ Feature: Manage user term """