Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: other

Settings API: Allow to unassign 'page_for_posts' and 'page_on_front' options
Original file line number Diff line number Diff line change
Expand Up @@ -1017,29 +1017,23 @@ function ( &$value ) {
break;

case 'page_on_front':
if ( ! $this->is_valid_page_id( $value ) ) {
break;
}
case 'page_for_posts':
if ( $value === '' ) { // empty function is not applicable here because '0' may be a valid page id
if ( delete_option( $key ) ) {
$updated[ $key ] = null;
}

$page_for_posts = get_option( 'page_for_posts' );
if ( $page_for_posts === $value ) {
// page for posts and page on front can't be the same
break;
}

if ( update_option( $key, $value ) ) {
$updated[ $key ] = $value;
}

break;
case 'page_for_posts':
if ( ! $this->is_valid_page_id( $value ) ) {
break;
}

$page_on_front = get_option( 'page_on_front' );
if ( $page_on_front === $value ) {
// page on front and page for posts can't be the same
$related_option_key = $key === 'page_on_front' ? 'page_for_posts' : 'page_on_front';
$related_option_value = get_option( $related_option_key );
if ( $related_option_value === $value ) {
// page_on_front and page_for_posts are not allowed to be the same
break;
}

Expand Down