Changeset 8150

Show
Ignore:
Timestamp:
06/20/08 21:03:18 (5 months ago)
Author:
mdawaffe
Message:

crazyhorse: quickpress dashboard widget bug fixes, and submit feedback

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/crazyhorse/wp-admin/includes/dashboard.php

    r8143 r8150  
    3838 
    3939    // QuickPress Widget 
     40    if ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['action'] ) && 0 === strpos( $_POST['action'], 'post-quickpress' ) ) { 
     41        $view = get_permalink( $_POST['post_ID'] ); 
     42        $edit = clean_url( get_edit_post_link( $_POST['post_ID'] ) ); 
     43        if ( 'post-quickpress-publish' == $_POST['action'] ) 
     44            $notice = sprintf( __( 'Post Published. <a href="%s">View post</a> | <a href="%s">Edit post</a>' ), clean_url( $view ), $edit ); 
     45        else 
     46            $notice = sprintf( __( 'Draft Saved. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ), clean_url( add_query_arg( 'preview', 1, $view ) ), $edit ); 
     47    } else { 
     48        $notice = ''; 
     49    } 
    4050    wp_register_sidebar_widget( 'dashboard_quick_press', __( 'QuickPress' ), 'wp_dashboard_quick_press', 
    41         array( 'width' => 'half', 'height' => 'double'
     51        array( 'width' => 'half', 'height' => 'double', 'notice' => $notice
    4252    ); 
    4353 
     
    298308 
    299309        <p class="submit"> 
    300             <input type="hidden" name="action" value="post-quickpress" /> 
     310            <input type="hidden" name="action" id="quickpost-action" value="post-quickpress-save" /> 
    301311            <?php wp_nonce_field('add-post'); ?> 
    302312            <input type="submit" name="save" id="save-post" class="button" value="<?php _e('Save'); ?>" /> 
     
    347357/* <![CDATA[ */ 
    348358var quickPressLoad = function($) { 
     359    var act = $('#quickpost-action'); 
    349360    var t = $('#quick-press').submit( function() { 
    350         t.load( t.attr( 'action' ) + ' #quick-press', t.serializeArray(), function() { 
     361        var head = $('#dashboard_quick_press div.dashboard-widget').children( 'div').hide().end().children('h3'); 
     362        head.html( '<span>' + head.html() + '</span><img src="images/loading.gif" style="margin-top: 6px; float: right" /><br class="clear" />' ); 
     363 
     364        if ( 'post' == act.val() ) { act.val( 'post-quickpress-publish' ); } 
     365 
     366        if ( 'undefined' != typeof tinyMCE ) { 
     367            tinyMCE.get('quickpress-content').save(); 
     368            tinyMCE.get('quickpress-content').remove(); 
     369        } 
     370 
     371        $('#dashboard_quick_press').load( t.attr( 'action' ) + ' #dashboard_quick_press div.dashboard-widget', t.serializeArray(), function() { 
     372            if ( 'undefined' != typeof wpTeenyMCEInit && $.isFunction( wpTeenyMCEInit ) ) { wpTeenyMCEInit(); } 
    351373            quickPressLoad($); 
    352             if ( 'undefined' != typeof wpTeenyMCEInit && $.isFunction( wpTeenyMCEInit ) ) { wpTeenyMCEInit(); } 
    353374        } ); 
    354375        return false; 
    355376    } ); 
    356     $('#publish').click( function() { t.append( "<input type='hidden' name='publish' value='publish' />" ); } ); 
     377 
     378    $('#publish').click( function() { act.val( 'post-quickpress-publish' ); } ); 
    357379}; 
    358380jQuery( quickPressLoad ); 
  • branches/crazyhorse/wp-admin/post.php

    r8143 r8150  
    5858 
    5959switch($action) { 
    60 case 'post-quickpress': 
    61     require_once(ABSPATH . 'wp-admin/includes/dashboard.php'); 
    62     add_filter( 'wp_dashboard_widgets', create_function( '$a', 'return array( "dashboard_quick_press" );' ) ); 
    63     wp_dashboard_setup(); 
    64     wp_dashboard(); 
    65     // no break 
    6660case 'postajaxpost': 
    6761case 'post': 
     62case 'post-quickpress-publish': 
     63case 'post-quickpress-save': 
    6864    check_admin_referer('add-post'); 
     65 
     66    if ( 'post-quickpress-publish' == $action ) 
     67        $_POST['publish'] = 'publish'; // tell write_post() to publish 
    6968 
    7069    $post_ID = 'postajaxpost' == $action ? edit_post() : write_post(); 
    7170 
    72     if ( 'post-quickpress' !== $action ) 
    73         redirect_post($post_ID); 
     71    if ( 0 === strpos( $action, 'post-quickpress' ) ) { 
     72        $_POST['post_ID'] = $post_ID; 
     73        // output the quickpress dashboard widget 
     74        require_once(ABSPATH . 'wp-admin/includes/dashboard.php'); 
     75        add_filter( 'wp_dashboard_widgets', create_function( '$a', 'return array( "dashboard_quick_press" );' ) ); 
     76        wp_dashboard_setup(); 
     77        wp_dashboard(); 
     78        exit; 
     79    } 
     80 
     81    redirect_post($post_ID); 
    7482    exit(); 
    7583    break;