Make WordPress Core

Changeset 32983


Ignore:
Timestamp:
06/28/2015 04:58:56 AM (10 years ago)
Author:
azaozz
Message:

Press This:

  • Save a draft before opening the standard editor window.
  • While saving a post show Saving... instead of Publish for the main visible part of the split button (same as the Save Draft button before).

See #32757.

Location:
trunk/src/wp-admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/press-this.css

    r32934 r32983  
    18891889}
    18901890
     1891.publish-button .saving-draft,
     1892.publish-button.is-saving .publish {
     1893    display: none;
     1894}
     1895
     1896.publish-button.is-saving .saving-draft {
     1897    display: inline;
     1898}
     1899
    18911900/* TinyMCE styles */
    18921901.editor .wp-media-buttons {
  • trunk/src/wp-admin/includes/class-wp-press-this.php

    r32944 r32983  
    147147            }
    148148
     149            $forceRedirect = false;
     150
    149151            if ( 'publish' === get_post_status( $post_id ) ) {
    150152                $redirect = get_post_permalink( $post_id );
     153            } elseif ( isset( $_POST['pt-force-redirect'] ) && $_POST['pt-force-redirect'] === 'true' ) {
     154                $forceRedirect = true;
     155                $redirect = get_edit_post_link( $post_id, 'js' );
    151156            } else {
    152157                $redirect = false;
     
    166171
    167172            if ( $redirect ) {
    168                 wp_send_json_success( array( 'redirect' => $redirect ) );
     173                wp_send_json_success( array( 'redirect' => $redirect, 'force' => $forceRedirect ) );
    169174            } else {
    170175                wp_send_json_success( array( 'postSaved' => true ) );
     
    13301335        <input type="hidden" name="wp-preview" id="wp-preview" value="" />
    13311336        <input type="hidden" name="post_title" id="post_title" value="" />
     1337        <input type="hidden" name="pt-force-redirect" id="pt-force-redirect" value="" />
    13321338        <?php
    13331339
     
    14571463            <div class="split-button">
    14581464                <div class="split-button-head">
    1459                     <button type="button" class="publish-button split-button-primary"><?php
    1460                         echo ( current_user_can( 'publish_posts' ) ) ? __( 'Publish' ) : __( 'Submit for Review' );
    1461                     ?></button><button type="button" class="split-button-toggle" aria-haspopup="true" aria-expanded="false">
     1465                    <button type="button" class="publish-button split-button-primary" aria-live="polite">
     1466                        <span class="publish"><?php echo ( current_user_can( 'publish_posts' ) ) ? __( 'Publish' ) : __( 'Submit for Review' ); ?></span>
     1467                        <span class="saving-draft"><?php _e( 'Saving...' ); ?></span>
     1468                    </button><button type="button" class="split-button-toggle" aria-haspopup="true" aria-expanded="false">
    14621469                        <i class="dashicons dashicons-arrow-down-alt2"></i>
    14631470                        <span class="screen-reader-text"><?php _e('More actions'); ?></span>
     
    14651472                </div>
    14661473                <ul class="split-button-body">
    1467                     <li><button type="button" class="button-subtle draft-button split-button-option" aria-live="polite"><?php _e( 'Save Draft' ); ?></button></li>
    1468                     <li><a href="<?php echo esc_url( get_edit_post_link( $post_ID ) ); ?>" class="edit-post-link split-button-option" target="_blank"><?php _e( 'Standard Editor' ); ?></a></li>
     1474                    <li><button type="button" class="button-subtle draft-button split-button-option"><?php _e( 'Save Draft' ); ?></button></li>
     1475                    <li><button type="button" class="button-subtle standard-editor-button split-button-option"><?php _e( 'Standard Editor' ); ?></button></li>
    14691476                    <li><button type="button" class="button-subtle preview-button split-button-option"><?php _e( 'Preview' ); ?></button></li>
    14701477                </ul>
  • trunk/src/wp-admin/js/press-this.js

    r32966 r32983  
    183183                hideSpinner();
    184184                clearNotices();
     185                $( '.publish-button' ).removeClass( 'is-saving' );
    185186            }).done( function( response ) {
    186187                if ( ! response.success ) {
    187188                    renderError( response.data.errorMessage );
    188189                } else if ( response.data.redirect ) {
    189                     if ( window.opener && settings.redirInParent ) {
     190                    if ( window.opener && ( settings.redirInParent || response.data.force ) ) {
    190191                        try {
    191192                            window.opener.location.href = response.data.redirect;
    192                         } catch( er ) {}
    193 
    194                         window.self.close();
     193
     194                            window.setTimeout( function() {
     195                                window.self.close();
     196                            }, 200 )
     197                        } catch( er ) {
     198                            window.location.href = response.data.redirect;
     199                        }
    195200                    } else {
    196201                        window.location.href = response.data.redirect;
    197202                    }
    198                 } else if ( response.data.postSaved ) {
    199                     // consider showing "Saved" message
    200203                }
    201204            }).fail( function() {
     
    661664                if ( $button.length ) {
    662665                    if ( $button.hasClass( 'draft-button' ) ) {
     666                        $( '.publish-button' ).addClass( 'is-saving' );
    663667                        submitPost( 'draft' );
    664668                    } else if ( $button.hasClass( 'publish-button' ) ) {
     669                        $button.addClass( 'is-saving' );
    665670                        submitPost( 'publish' );
    666671                    } else if ( $button.hasClass( 'preview-button' ) ) {
     
    671676                        $( '#pressthis-form' ).attr( 'target', '_blank' ).submit().attr( 'target', '' );
    672677                        $( '#wp-preview' ).val( '' );
     678                    } else if ( $button.hasClass( 'standard-editor-button' ) ) {
     679                        $( '.publish-button' ).addClass( 'is-saving' );
     680                        $( '#pt-force-redirect' ).val( 'true' );
     681                        submitPost( 'draft' );
    673682                    } else if ( $button.hasClass( 'split-button-toggle' ) ) {
    674683                        if ( $splitButton.hasClass( 'is-open' ) ) {
     
    680689                        }
    681690                    }
    682                 } else if ( $target.hasClass( 'edit-post-link' ) && window.opener ) {
    683                     window.opener.focus();
    684                     window.self.close();
    685691                }
    686692            });
Note: See TracChangeset for help on using the changeset viewer.