Privacy: On Privacy Settings screen, check if any pages exist before displaying the page selector.

Props abdullahramzan, desrosj, melchoyce.
Fixes #43940.

git-svn-id: https://develop.svn.wordpress.org/trunk@43238 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2018-05-10 21:38:45 +00:00
parent 70fd932c25
commit 2dbb76084d
1 changed files with 38 additions and 20 deletions

View File

@ -167,9 +167,20 @@ require_once( ABSPATH . 'wp-admin/admin-header.php' );
?> ?>
</th> </th>
<td> <td>
<?php
$has_pages = (bool) get_posts( array(
'post_type' => 'page',
'posts_per_page' => 1,
'post_status' => array(
'publish',
'draft',
),
) );
if ( $has_pages ) : ?>
<form method="post" action=""> <form method="post" action="">
<label for="page_for_privacy_policy"> <label for="page_for_privacy_policy">
<?php _e( 'Either select an existing page:' ); ?> <?php _e( 'Select an existing page:' ); ?>
</label> </label>
<input type="hidden" name="action" value="set-privacy-page" /> <input type="hidden" name="action" value="set-privacy-page" />
<?php <?php
@ -188,11 +199,18 @@ require_once( ABSPATH . 'wp-admin/admin-header.php' );
submit_button( __( 'Use This Page' ), 'primary', 'submit', false, array( 'id' => 'set-page' ) ); submit_button( __( 'Use This Page' ), 'primary', 'submit', false, array( 'id' => 'set-page' ) );
?> ?>
</form> </form>
<?php endif; ?>
<form method="post" action=""> <form method="post" action="">
<input type="hidden" name="action" value="create-privacy-page" /> <input type="hidden" name="action" value="create-privacy-page" />
<span> <span>
<?php _e( 'Or create a new page:' ); ?> <?php
if ( $has_pages ) {
_e( 'Or:' );
} else {
_e( 'There are no pages.' );
}
?>
</span> </span>
<?php <?php
wp_nonce_field( 'create-privacy-page' ); wp_nonce_field( 'create-privacy-page' );