Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion features/comment-recount.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Feature: Recount comments on a post
"""
<?php
global $wpdb;
$wpdb->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`
Expand Down
4 changes: 2 additions & 2 deletions features/option-pluck-patch.feature
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@ Feature: Option commands have pluck and patch.
And a setup.php file:
"""
<?php
$option = new stdClass;
$option = new stdClass();
$option->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`

Expand Down
27 changes: 16 additions & 11 deletions features/post-block.feature
Original file line number Diff line number Diff line change
Expand Up @@ -565,17 +565,22 @@ Feature: Manage blocks in post content
And a custom-sync-filter.php file:
"""
<?php
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(
'/<p([^>]*)>/',
'<p class="' . esc_attr( $new_attrs['customClass'] ) . '"$1>',
$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(
'/<p([^>]*)>/',
'<p class="' . esc_attr( $new_attrs['customClass'] ) . '"$1>',
$block['innerHTML']
);
$block['innerContent'] = [ $block['innerHTML'] ];
}
return $block;
},
10,
3
);
"""
When I run `wp post create --post_title="Block Post" --post_content="<!-- wp:paragraph --><p>Hello World</p><!-- /wp:paragraph -->" --porcelain`
Then save STDOUT as {POST_ID}
Expand Down
2 changes: 1 addition & 1 deletion features/post-meta.feature
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ Feature: Manage post custom fields
And a setup.php file:
"""
<?php
update_post_meta( 1, 'foo', NULL );
update_post_meta( 1, 'foo', null );
"""
And I run `wp eval-file setup.php`

Expand Down
64 changes: 32 additions & 32 deletions features/taxonomy.feature
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,22 @@ Feature: Manage WordPress taxonomies
"""
<?php
// Plugin Name: Test Taxonomy Strict/No-Strict Mode

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 );
} );
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`
Expand All @@ -94,22 +94,22 @@ Feature: Manage WordPress taxonomies
"""
<?php
// Plugin Name: Test Taxonomy Strict/No-Strict Mode

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 );
} );
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`
Expand Down
12 changes: 7 additions & 5 deletions features/term-migrate.feature
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,13 @@ Feature: Migrate term custom fields
"""
<?php
// Plugin Name: Test Migrate

add_action( 'init', function() {
register_post_type( 'news', [ 'public' => 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`
Expand Down
4 changes: 2 additions & 2 deletions features/term-recount.feature
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ Feature: Recount terms on a taxonomy
"""
<?php
global $wpdb;
$wpdb->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`
Expand Down
16 changes: 6 additions & 10 deletions features/user-term.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ Feature: Manage user term
"""
<?php
// Plugin Name: Test Add Tax

function add_cli_tax(){
register_taxonomy( 'user_type', 'user' );
function add_cli_tax() {
register_taxonomy( 'user_type', 'user' );
}

add_action('init','add_cli_tax');
add_action( 'init', 'add_cli_tax' );
"""
And I run `wp plugin activate test-add-tax`

Expand Down Expand Up @@ -75,12 +73,10 @@ Feature: Manage user term
"""
<?php
// Plugin Name: Test Add Tax

function add_cli_tax(){
register_taxonomy( 'user_type', 'user' );
function add_cli_tax() {
register_taxonomy( 'user_type', 'user' );
}

add_action('init','add_cli_tax');
add_action( 'init', 'add_cli_tax' );
"""
And I run `wp plugin activate test-add-tax`

Expand Down
Loading