Make WordPress Core


Ignore:
Timestamp:
04/03/2015 01:33:30 AM (10 years ago)
Author:
azaozz
Message:

Press This:

  • Show a spinner while saving a post.
  • Do not redirect after saving a draft.
  • Make the unidentified error message clearer.

Fixes #31875.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-press-this.php

    r31930 r31992  
    149149
    150150            if ( 'publish' === get_post_status( $post_id ) ) {
    151                 /**
    152                  * Filter the URL to redirect to when Press This saves.
    153                  *
    154                  * @since 4.2.0
    155                  *
    156                  * @param string $url     Redirect URL. If `$status` is 'publish', this will be the post permalink.
    157                  *                        Otherwise, the post edit URL will be used.
    158                  * @param int    $post_id Post ID.
    159                  * @param string $status  Post status.
    160                  */
    161                 $redirect = apply_filters( 'press_this_save_redirect', get_post_permalink( $post_id ), $post_id, $post['post_status'] );
     151                $redirect = get_post_permalink( $post_id );
    162152            } else {
    163                 /** This filter is documented in wp-admin/includes/class-wp-press-this.php */
    164                 $redirect = apply_filters( 'press_this_save_redirect', get_edit_post_link( $post_id, 'raw' ), $post_id, $post['post_status'] );
    165             }
    166 
    167             wp_send_json_success( array( 'redirect' => $redirect ) );
     153                $redirect = false;
     154            }
     155
     156            /**
     157             * Filter the URL to redirect to when Press This saves.
     158             *
     159             * @since 4.2.0
     160             *
     161             * @param string $url     Redirect URL. If `$status` is 'publish', this will be the post permalink.
     162             *                        Otherwise, the post edit URL will be used.
     163             * @param int    $post_id Post ID.
     164             * @param string $status  Post status.
     165             */
     166            $redirect = apply_filters( 'press_this_save_redirect', $redirect, $post_id, $post['post_status'] );
     167
     168            if ( $redirect ) {
     169                wp_send_json_success( array( 'redirect' => $redirect ) );
     170            } else {
     171                wp_send_json_success( array( 'postSaved' => true ) );
     172            }
    168173        }
    169174    }
     
    13401345        </div>
    13411346        <div class="post-actions">
     1347            <span class="spinner">&nbsp;</span>
    13421348            <button type="button" class="button-subtle draft-button"><?php _e( 'Save Draft' ); ?></button>
    13431349            <button type="button" class="button-subtle preview-button"><?php _e( 'Preview' ); ?></button>
Note: See TracChangeset for help on using the changeset viewer.