Make WordPress Core

Changeset 9639


Ignore:
Timestamp:
11/12/2008 06:36:48 PM (18 years ago)
Author:
markjaquith
Message:

Visibility section of Publish Module for Posts. Pages later.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-form-advanced.php

    r9620 r9639  
    9393
    9494<div id="save-action">
    95 <?php if ( 'publish' != $post->post_status && 'private' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status )  { ?>
    96 <input type="submit" name="save" id="save-post" value="<?php echo attribute_escape( __('Save Draft') ); ?>" tabindex="4" class="button button-highlighted" />
     95<?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status )  { ?>
     96<input <?php if ( 'private' == $post->post_status ) { ?>style="display:none"<?php } ?> type="submit" name="save" id="save-post" value="<?php echo attribute_escape( __('Save Draft') ); ?>" tabindex="4" class="button button-highlighted" />
    9797<?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?>
    9898<input type="submit" name="save" id="save-post" value="<?php echo attribute_escape( __('Save as Pending') ); ?>" tabindex="4" class="button button-highlighted" />
     
    114114<?php
    115115switch ( $post->post_status ) {
     116        case 'private':
     117                _e('Privately Published');
     118                break;
    116119        case 'publish':
    117         case 'private':
    118120                _e('Published');
    119121                break;
     
    131133</span></b>
    132134<?php if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) { ?>
    133 <a href="#post_status" class="edit-post-status hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a>
     135<a href="#post_status" <?php if ( 'private' == $post->post_status ) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a>
    134136
    135137<div id="post-status-select" class="hide-if-js">
    136138<input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo $post->post_status; ?>" />
    137139<select name='post_status' id='post_status' tabindex='4'>
    138 <?php if ( $post->post_status == 'publish' ) : ?>
    139 <option<?php selected( $post->post_status, 'publish' ); selected( $post->post_status, 'private' );?> value='publish'><?php _e('Published') ?></option>
     140<?php if ( 'publish' == $post->post_status ) : ?>
     141<option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e('Published') ?></option>
     142<?php elseif ( 'private' == $post->post_status ) : ?>
     143<option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e('Privately Published') ?></option>
    140144<?php elseif ( 'future' == $post->post_status ) : ?>
    141145<option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option>
     
    151155</div><?php // /misc-pub-section ?>
    152156
    153 
    154 <?php if ( $can_publish && current_user_can( 'edit_others_posts' ) ) { ?>
    155 <div class="misc-pub-section " id="sticky-checkbox">
    156 <input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked(is_sticky($post->ID), true); ?> tabindex="4" /> <label for="sticky" class="selectit"><?php _e('Stick this post to the front page') ?></label>
     157<div class="misc-pub-section " id="visibility">
     158<?php _e('Visibility:'); ?> <b><span id="post-visibility-display"><?php
     159
     160if ( !empty( $post->post_password ) ) {
     161        $visibility = 'password';
     162        $visibility_trans = __('Password protected');
     163} elseif ( 'private' == $post->post_status ) {
     164        $visibility = 'private';
     165        $visibility_trans = __('Private');
     166} elseif ( is_sticky( $post->ID ) ) {
     167        $visibility = 'public';
     168        $visibility_trans = __('Public, sticky');
     169        $sticky = 'sticky';
     170} else {
     171        $visibility = 'public';
     172        $visibility_trans = __('Public');
     173}
     174
     175?><?php echo wp_specialchars( $visibility_trans ); ?></span></b> <?php if ( $can_publish ) { ?> <a href="#visibility" class="edit-visibility hide-if-no-js"><?php _e('Edit'); ?></a>
     176
     177<div id="post-visibility-select" class="hide-if-js">
     178<input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo attribute_escape($post->post_password); ?>" />
     179<input type="checkbox" style="display:none" name="hidden_post_sticky" id="hidden-post-sticky" value="sticky" <?php checked(is_sticky($post->ID), true); ?> />
     180<input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo attribute_escape( $visibility ); ?>" />
     181
     182
     183<input type="radio" name="visibility" id="visibility-radio-public" value="public" <?php checked( $visibility, 'public' ); ?> /> <label for="visibility-radio-public" class="selectit"><?php _e('Public'); ?></label><br />
     184<span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked(is_sticky($post->ID), true); ?> tabindex="4" /> <label for="sticky" class="selectit"><?php _e('Stick this post to the front page') ?></label><br /></span>
     185<input type="radio" name="visibility" id="visibility-radio-password" value="password" <?php checked( $visibility, 'password' ); ?> /> <label for="visibility-radio-password" class="selectit"><?php _e('Password protected'); ?></label><br />
     186<span id="password-span"><label for="post_password"><?php _e('Password:'); ?></label> <input type="text" name="post_password" id="post_password" value="<?php echo attribute_escape($post->post_password); ?>" /><br /></span>
     187<input type="radio" name="visibility" id="visibility-radio-private" value="private" <?php checked( $visibility, 'private' ); ?> /> <label for="visibility-radio-private" class="selectit"><?php _e('Private'); ?></label><br />
     188
     189<p>
     190 <a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e('OK'); ?></a>
     191 <a href="#visibility" class="cancel-post-visibility hide-if-no-js"><?php _e('Cancel'); ?></a>
     192</p>
     193</div>
     194<?php } ?>
     195
    157196</div><?php // /misc-pub-section ?>
    158 <?php } ?>
    159197
    160198
     
    164202        if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date
    165203                $stamp = __('Scheduled for: <b>%1$s</b>');
    166         } else if ( 'publish' == $post->post_status ) { // already published
     204        } else if ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published
    167205                $stamp = __('Published on: <b>%1$s</b>');
    168206        } else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified
     
    203241<div id="publishing-action">
    204242<?php
    205 if ( !in_array( $post->post_status, array('publish', 'future') ) || 0 == $post->ID ) { ?>
     243if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) { ?>
    206244<?php if ( current_user_can('publish_posts') ) : ?>
    207245        <?php if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?>
     246                <input name="original_publish" type="hidden" id="original_publish" value="<?php _e('Schedule') ?>" />
    208247                <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Schedule') ?>" />
    209248        <?php else : ?>
     249                <input name="original_publish" type="hidden" id="original_publish" value="<?php _e('Publish') ?>" />
    210250                <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" />
    211251        <?php endif; ?>
    212252<?php else : ?>
     253        <input name="original_publish" type="hidden" id="original_publish" value="<?php _e('Submit for Review') ?>" />
    213254        <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Submit for Review') ?>" />
    214255<?php endif; ?>
    215256<?php } else { ?>
     257        <input name="original_publish" type="hidden" id="original_publish" value="<?php _e('Update Post') ?>" />
    216258        <input name="save" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php _e('Update Post') ?>" />
    217259<?php } ?>
     
    301343<?php
    302344}
    303 add_meta_box('passworddiv', __('Privacy Options'), 'post_password_meta_box', 'post', 'side', 'core');
     345// add_meta_box('passworddiv', __('Privacy Options'), 'post_password_meta_box', 'post', 'side', 'core');
    304346
    305347/**
  • trunk/wp-admin/includes/post.php

    r9606 r9639  
    153153        if ( is_wp_error($post_data) )
    154154                wp_die( $post_data->get_error_message() );
     155
     156        switch ( $post_data['visibility'] ) {
     157                case 'public' :
     158                        unset( $post_data['post_password'] );
     159                        break;
     160                case 'password' :
     161                        unset( $post_data['sticky'] );
     162                        break;
     163                case 'private' :
     164                        $post_data['post_status'] = 'private';
     165                        $post_data['post_password'] = '';
     166                        unset( $post_data['sticky'] );
     167                        break;
     168        }
    155169
    156170        // Meta Stuff
     
    442456        if ( is_wp_error($translated) )
    443457                return $translated;
     458
     459        switch ( $_POST['visibility'] ) {
     460                case 'public' :
     461                        $_POST['post_password'] = '';
     462                        break;
     463                case 'password' :
     464                        unset( $_POST['sticky'] );
     465                        break;
     466                case 'private' :
     467                        $_POST['post_status'] = 'private';
     468                        $_POST['post_password'] = '';
     469                        unset( $_POST['sticky'] );
     470                        break;
     471        }
    444472
    445473        // Create the post.
  • trunk/wp-admin/js/post.js

    r9564 r9639  
    193193        jQuery('.categorychecklist .popular-category :checkbox').change( syncChecks ).filter( ':checked' ).change();
    194194        var stamp = $('#timestamp').html();
     195        var visibility = $('#post-visibility-display').html();
     196        var sticky = '';
     197
     198        function updateVisibility() {
     199                if ( $('#post-visibility-select input:radio:checked').val() != 'public' ) {
     200                        $('#sticky').attr('checked', false);
     201                        $('#sticky-span').hide();
     202                } else {
     203                        $('#sticky-span').show();
     204                }
     205                if ( $('#post-visibility-select input:radio:checked').val() != 'password' ) {
     206                        $('#password-span').hide();
     207                } else {
     208                        $('#password-span').show();
     209                }
     210        }
     211
     212        function updateText() {
     213                var attemptedDate = new Date( $('#aa').val(), $('#mm').val() -1, $('#jj').val(), $('#hh').val(), $('#mn').val());
     214                var originalDate = new Date( $('#hidden_aa').val(), $('#hidden_mm').val() -1, $('#hidden_jj').val(), $('#hidden_hh').val(), $('#hidden_mn').val());
     215                var currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val());
     216                if ( attemptedDate > currentDate ) {
     217                        var publishOn = postL10n.publishOnFuture;
     218                        $('#publish').val( postL10n.schedule );
     219                } else if ( $('#original_post_status').val() != 'publish' ) {
     220                        var publishOn = postL10n.publishOn;
     221                        $('#publish').val( postL10n.publish );
     222                } else {
     223                        var publishOn = postL10n.publishOnPast;
     224                        $('#publish').val( postL10n.update );
     225                }
     226                if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) { //hack
     227                        $('#timestamp').html(stamp);
     228                } else {
     229                        $('#timestamp').html(
     230                                publishOn + ' <b>' +
     231                                $( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' +
     232                                $('#jj').val() + ', ' +
     233                                $('#aa').val() + ' @ ' +
     234                                $('#hh').val() + ':' +
     235                                $('#mn').val() + '</b> '
     236                        );
     237                }
     238
     239                if ( $('#post-visibility-select input:radio:checked').val() == 'private' ) {
     240                        $('#publish').val( postL10n.update );
     241                        if ( $('#post_status option[value=publish]').length == 0 ) {
     242                                $('#post_status').append('<option value="publish">' + postL10n.privatelyPublished + '</option>');
     243                        }
     244                        $('#post_status option[value=publish]').html( postL10n.privatelyPublished );
     245                        $('#post_status option[value=publish]').attr('selected', true);
     246                        $('.edit-post-status').hide();
     247                } else {
     248                        if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) {
     249                                if ( $('#post_status option[value=publish]').length != 0 ) {
     250                                        $('#post_status option[value=publish]').remove();
     251                                        $('#post_status').val($('#hidden_post_status').val());
     252                                }
     253                        } else {
     254                                $('#post_status option[value=publish]').html( postL10n.published );
     255                        }
     256                        $('.edit-post-status').show();
     257                }
     258                $('#post-status-display').html($('#post_status :selected').text());
     259                if ( $('#post_status :selected').val() == 'private' || $('#post_status :selected').val() == 'publish' ) {
     260                        $('#save-post').hide();
     261                } else {
     262                        $('#save-post').show();
     263                        if ( $('#post_status :selected').val() == 'pending' ) {
     264                                $('#save-post').show().val( postL10n.savePending );
     265                        } else {
     266                                $('#save-post').show().val( postL10n.saveDraft );
     267                        }
     268                }
     269        }
     270
     271        $('.edit-visibility').click(function () {
     272                if ($('#post-visibility-select').is(":hidden")) {
     273                        updateVisibility();
     274                        $('#post-visibility-select').slideDown("normal");
     275                        $('.edit-visibility').hide();
     276                }
     277                return false;
     278        });
     279
     280        $('.cancel-post-visibility').click(function () {
     281                $('#post-visibility-select').slideUp("normal");
     282                $('#visibility-radio-' + $('#hidden-post-visibility').val()).attr('checked', true);
     283                $('#post_password').val($('#hidden_post_password').val());
     284                $('#sticky').attr('checked', $('#hidden-post-sticky').attr('checked'));
     285                $('#post-visibility-display').html(visibility);
     286                $('.edit-visibility').show();
     287                updateText();
     288                return false;
     289        });
     290
     291        $('.save-post-visibility').click(function () { // crazyhorse - multiple ok cancels
     292                $('#post-visibility-select').slideUp("normal");
     293                $('.edit-visibility').show();
     294                updateText();
     295                if ( $('#post-visibility-select input:radio:checked').val() != 'public' ) {
     296                        $('#sticky').attr('checked', false);
     297                }
     298
     299                if ( true == $('#sticky').attr('checked') ) {
     300                        sticky = 'Sticky';
     301                } else {
     302                        sticky = '';
     303                }
     304
     305                $('#post-visibility-display').html(
     306                        postL10n[$('#post-visibility-select input:radio:checked').val() + sticky]
     307                );
     308
     309                return false;
     310        });
     311
     312        $('#post-visibility-select input:radio').change(function() {
     313                updateVisibility();
     314        });
    195315
    196316        $('.edit-timestamp').click(function () {
     
    210330                $('#hh').val($('#hidden_hh').val());
    211331                $('#mn').val($('#hidden_mn').val());
    212                 $('#timestamp').html(stamp);
    213332                $('.edit-timestamp').show();
    214 
    215                 var attemptedDate = new Date( $('#aa').val(), $('#mm').val() -1, $('#jj').val(), $('#hh').val(), $('#mn').val() );
    216                 var currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val() );
    217                 if ( attemptedDate > currentDate ) {
    218                         $('#publish').val( postL10n.schedule );
    219                 } else if ( $('#original_post_status').val() != 'publish' ) {
    220                         $('#publish').val( postL10n.publish );
    221                 } else {
    222                         $('#publish').val( postL10n.update );
    223                 }
    224 
     333                updateText();
    225334                return false;
    226335        });
     
    229338                $('#timestampdiv').slideUp("normal");
    230339                $('.edit-timestamp').show();
    231                 var attemptedDate = new Date( $('#aa').val(), $('#mm').val() -1, $('#jj').val(), $('#hh').val(), $('#mn').val() );
    232                 var currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val() );
    233                 if ( attemptedDate > currentDate ) {
    234                         var publishOn = postL10n.publishOnFuture;
    235                         $('#publish').val( postL10n.schedule );
    236                 } else if ( $('#original_post_status').val() != 'publish' ) {
    237                         var publishOn = postL10n.publishOn;
    238                         $('#publish').val( postL10n.publish );
    239                 } else {
    240                         var publishOn = postL10n.publishOnPast;
    241                         $('#publish').val( postL10n.update );
    242                 }
    243                 $('#timestamp').html(
    244                         publishOn + ' <b>' +
    245                         $( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' +
    246                         $('#jj').val() + ', ' +
    247                         $('#aa').val() + ' @ ' +
    248                         $('#hh').val() + ':' +
    249                         $('#mn').val() + '</b> '
    250                 );
     340                updateText();
    251341
    252342                return false;
     
    264354        $('.save-post-status').click(function() {
    265355                $('#post-status-select').slideUp("normal");
    266                 $('#post-status-display').html($('#post_status :selected').text());
    267356                $('.edit-post-status').show();
    268                 if ( $('#post_status :selected').val() == 'pending' ) {
    269                         $('#save-post').val( postL10n.savePending );
    270                 } else {
    271                         $('#save-post').val( postL10n.saveDraft );
    272                 }
     357                updateText();
    273358                return false;
    274359        });
     
    277362                $('#post-status-select').slideUp("normal");
    278363                $('#post_status').val($('#hidden_post_status').val());
    279                 $('#post-status-display').html($('#post_status :selected').text());
    280364                $('.edit-post-status').show();
    281                 if ( $('#post_status :selected').val() == 'pending' ) {
    282                         $('#save-post').val( postL10n.savePending );
    283                 } else {
    284                         $('#save-post').val( postL10n.saveDraft );
    285                 }
    286 
     365                updateText();
    287366                return false;
    288367        });
  • trunk/wp-admin/wp-admin.css

    r9616 r9639  
    302302#post-body .misc-pub-section-last {
    303303        border-right: 0;
     304}
     305
     306#sticky-span {
     307        margin-left: 18px;
    304308}
    305309
  • trunk/wp-includes/script-loader.php

    r9631 r9639  
    192192                        'update' => __('Update Post'),
    193193                        'savePending' => __('Save as Pending'),
    194                         'saveDraft' => __('Save Draft')
     194                        'saveDraft' => __('Save Draft'),
     195                        'private' => __('Private'),
     196                        'public' => __('Public'),
     197                        'publicSticky' => __('Public, sticky'),
     198                        'password' => __('Password protected'),
     199                        'privatelyPublished' => __('Privately Published'),
     200                        'published' => __('Published')
     201                       
    195202                ) );
    196203                $scripts->add( 'page', '/wp-admin/js/page.js', array('jquery', 'slug', 'wp-lists', 'postbox'), '20081107' );
     
    291298        $rtl_styles = array( 'global', 'colors', 'dashboard', 'ie', 'install', 'login', 'media', 'theme-editor', 'upload', 'widgets', 'press-this', 'press-this-ie', 'plugin-install', 'farbtastic' );
    292299
    293         $styles->add( 'wp-admin', '/wp-admin/wp-admin.css', array(), '20081110' );
     300        $styles->add( 'wp-admin', '/wp-admin/wp-admin.css', array(), '20081112' );
    294301        $styles->add_data( 'wp-admin', 'rtl', '/wp-admin/rtl.css' );
    295302
Note: See TracChangeset for help on using the changeset viewer.