Make WordPress Core

Changeset 43239


Ignore:
Timestamp:
05/10/2018 09:40:28 PM (8 years ago)
Author:
SergeyBiryukov
Message:

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

Props abdullahramzan, desrosj, melchoyce.
Merges [43238] to the 4.9 branch.
Fixes #43940.

Location:
branches/4.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

  • branches/4.9/src/wp-admin/privacy.php

    r43219 r43239  
    168168                        </th>
    169169                        <td>
    170                                 <form method="post" action="">
    171                                         <label for="page_for_privacy_policy">
    172                                                 <?php _e( 'Either select an existing page:' ); ?>
    173                                         </label>
    174                                         <input type="hidden" name="action" value="set-privacy-page" />
    175                                         <?php
    176                                         wp_dropdown_pages(
    177                                                 array(
    178                                                         'name'              => 'page_for_privacy_policy',
    179                                                         'show_option_none'  => __( '&mdash; Select &mdash;' ),
    180                                                         'option_none_value' => '0',
    181                                                         'selected'          => $privacy_policy_page_id,
    182                                                         'post_status'       => array( 'draft', 'publish' ),
    183                                                 )
    184                                         );
    185 
    186                                         wp_nonce_field( 'set-privacy-page' );
    187 
    188                                         submit_button( __( 'Use This Page' ), 'primary', 'submit', false, array( 'id' => 'set-page' ) );
    189                                         ?>
    190                                 </form>
     170                                <?php
     171                                $has_pages = (bool) get_posts( array(
     172                                        'post_type' => 'page',
     173                                        'posts_per_page' => 1,
     174                                        'post_status' => array(
     175                                                'publish',
     176                                                'draft',
     177                                        ),
     178                                ) );
     179
     180                                if ( $has_pages ) : ?>
     181                                        <form method="post" action="">
     182                                                <label for="page_for_privacy_policy">
     183                                                        <?php _e( 'Select an existing page:' ); ?>
     184                                                </label>
     185                                                <input type="hidden" name="action" value="set-privacy-page" />
     186                                                <?php
     187                                                wp_dropdown_pages(
     188                                                        array(
     189                                                                'name'              => 'page_for_privacy_policy',
     190                                                                'show_option_none'  => __( '&mdash; Select &mdash;' ),
     191                                                                'option_none_value' => '0',
     192                                                                'selected'          => $privacy_policy_page_id,
     193                                                                'post_status'       => array( 'draft', 'publish' ),
     194                                                        )
     195                                                );
     196
     197                                                wp_nonce_field( 'set-privacy-page' );
     198
     199                                                submit_button( __( 'Use This Page' ), 'primary', 'submit', false, array( 'id' => 'set-page' ) );
     200                                                ?>
     201                                        </form>
     202                                <?php endif; ?>
    191203
    192204                                <form method="post" action="">
    193205                                        <input type="hidden" name="action" value="create-privacy-page" />
    194206                                        <span>
    195                                                 <?php _e( 'Or create a new page:' ); ?>
     207                                                <?php
     208                                                if ( $has_pages ) {
     209                                                        _e( 'Or:' );
     210                                                } else {
     211                                                        _e( 'There are no pages.' );
     212                                                }
     213                                                ?>
    196214                                        </span>
    197215                                        <?php
Note: See TracChangeset for help on using the changeset viewer.