Skip to content

Commit af461e3

Browse files
Merge pull request #236 from thrijith/feature/update-site-empty
Reset option value to default for privacy policy on site empty
2 parents 6132db5 + 4adc5db commit af461e3

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

features/site-empty.feature

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@ Feature: Empty a WordPress site of its data
2929
Success: Created post_tag 2.
3030
"""
3131

32+
When I run `wp post create --post_type=page --post_title='Sample Privacy Page' --post_content='Sample Privacy Terms' --porcelain`
33+
Then save STDOUT as {PAGE_ID}
34+
35+
When I run `wp option set wp_page_for_privacy_policy {PAGE_ID}`
36+
Then STDOUT should be:
37+
"""
38+
Success: Updated 'wp_page_for_privacy_policy' option.
39+
"""
40+
41+
When I run `wp option get wp_page_for_privacy_policy`
42+
Then STDOUT should be:
43+
"""
44+
{PAGE_ID}
45+
"""
46+
3247
When I run `wp site empty --yes`
3348
Then STDOUT should be:
3449
"""
@@ -42,6 +57,12 @@ Feature: Empty a WordPress site of its data
4257
When I run `wp term list post_tag --format=ids`
4358
Then STDOUT should be empty
4459

60+
When I run `wp option get wp_page_for_privacy_policy`
61+
Then STDOUT should be:
62+
"""
63+
0
64+
"""
65+
4566
Scenario: Empty a site and its uploads directory
4667
Given a WP multisite installation
4768
And I run `wp site create --slug=foo`

src/Site_Command.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ private function _insert_default_terms() {
135135
$wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 0));
136136
}
137137

138+
/**
139+
* Reset option values to default.
140+
*/
141+
private function _reset_options() {
142+
// Reset Privacy Policy value to prevent error.
143+
update_option( 'wp_page_for_privacy_policy', 0 );
144+
}
145+
138146
/**
139147
* Empties a site of its content (posts, comments, terms, and meta).
140148
*
@@ -186,6 +194,7 @@ public function _empty( $args, $assoc_args ) {
186194
$this->_empty_comments();
187195
$this->_empty_taxonomies();
188196
$this->_insert_default_terms();
197+
$this->_reset_options();
189198

190199
if ( ! empty( $upload_message ) ) {
191200
$upload_dir = wp_upload_dir();

0 commit comments

Comments
 (0)