Skip to content

Commit e1fb981

Browse files
committed
Update site empty feature to handle sticky posts
1 parent 497bb46 commit e1fb981

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

features/site-empty.feature

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ Feature: Empty a WordPress site of its data
4444
{PAGE_ID}
4545
"""
4646

47+
When I run `wp post create --post_title='Sticky Post' --post_content='This is just a sticky post' --porcelain`
48+
Then save STDOUT as {STICKY_POST_ID}
49+
50+
When I run `wp option set sticky_posts '[{STICKY_POST_ID}]' --format=json`
51+
Then STDOUT should be:
52+
"""
53+
Success: Updated 'sticky_posts' option.
54+
"""
55+
4756
When I run `wp site empty --yes`
4857
Then STDOUT should be:
4958
"""
@@ -63,6 +72,12 @@ Feature: Empty a WordPress site of its data
6372
0
6473
"""
6574

75+
When I run `wp option get sticky_posts --format=json`
76+
Then STDOUT should be:
77+
"""
78+
[]
79+
"""
80+
6681
Scenario: Empty a site and its uploads directory
6782
Given a WP multisite installation
6883
And I run `wp site create --slug=foo`

src/Site_Command.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ private function insert_default_terms() {
176176
private function reset_options() {
177177
// Reset Privacy Policy value to prevent error.
178178
update_option( 'wp_page_for_privacy_policy', 0 );
179+
180+
// Reset sticky posts option.
181+
update_option( 'sticky_posts', [] );
179182
}
180183

181184
/**

0 commit comments

Comments
 (0)