Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_dashboard_quick_press [ WordPress Function ]

wp_dashboard_quick_press ( No parameters )
Defined at:



No description yet.

Source


<?php
function wp_dashboard_quick_press() {
    global 
$post_ID;

    
$drafts false;
    if ( 
'post' === strtolower$_SERVER['REQUEST_METHOD'] ) && isset( $_POST['action'] ) && === strpos$_POST['action'], 'post-quickpress' ) && (int) $_POST['post_ID'] ) {
        
$view get_permalink$_POST['post_ID'] );
        
$edit esc_urlget_edit_post_link$_POST['post_ID'] ) );
        if ( 
'post-quickpress-publish' == $_POST['action'] ) {
            if ( 
current_user_can('publish_posts') )
                
printf'<div class="updated"><p>' __'Post published. <a href="%s">View post</a> | <a href="%s">Edit post</a>' ) . '</p></div>'esc_url$view ), $edit );
            else
                
printf'<div class="updated"><p>' __'Post submitted. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>'esc_urladd_query_arg'preview'1$view ) ), $edit );
        } else {
            
printf'<div class="updated"><p>' __'Draft saved. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>'esc_urladd_query_arg'preview'1$view ) ), $edit );
            
$drafts_query = new WP_Query( array(
                
'post_type' => 'post',
                
'post_status' => 'draft',
                
'author' => $GLOBALS['current_user']->ID,
                
'posts_per_page' => 1,
                
'orderby' => 'modified',
                
'order' => 'DESC'
            
) );

            if ( 
$drafts_query->posts )
                
$drafts =& $drafts_query->posts;
        }
        
printf('<p class="textright">' __('You can also try %s, easy blogging from anywhere on the Web.') . '</p>''<a href="' esc_urladmin_url'tools.php' ) ) . '">' __('Press This') . '</a>' );
        
$_REQUEST = array(); // hack for get_default_post_to_edit()
    
}

    
/* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */
    
$last_post_id = (int) get_user_option'dashboard_quick_press_last_post_id' ); // Get the last post_ID
    
if ( $last_post_id ) {
        
$post get_post$last_post_id );
        if ( empty( 
$post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore
            
$post get_default_post_to_edit('post'true);
            
update_user_option( (int) $GLOBALS['current_user']->ID'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
        
} else {
            
$post->post_title ''// Remove the auto draft title
        
}
    } else {
        
$post get_default_post_to_edit('post'true);
        
update_user_option( (int) $GLOBALS['current_user']->ID'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
    
}

    
$post_ID = (int) $post->ID;
?>

    <form name="post" action="<?php echo esc_urladmin_url'post.php' ) ); ?>" method="post" id="quick-press">
        <h4 id="quick-post-title"><label for="title"><?php _e('Title'?></label></h4>
        <div class="input-text-wrap">
            <input type="text" name="post_title" id="title" tabindex="1" autocomplete="off" value="<?php echo esc_attr$post->post_title ); ?>" />
        </div>

        <?php if ( current_user_can'upload_files' ) ) : ?>
        <div id="wp-content-wrap" class="wp-editor-wrap hide-if-no-js wp-media-buttons">
            <?php do_action'media_buttons''content' ); ?>
        </div>
        <?php endif; ?>

        <h4 id="content-label"><label for="content"><?php _e('Content'?></label></h4>
        <div class="textarea-wrap">
            <textarea name="content" id="content" class="mceEditor" rows="3" cols="15" tabindex="2"><?php echo esc_textarea$post->post_content ); ?></textarea>
        </div>

        <script type="text/javascript">edCanvas = document.getElementById('content');edInsertContent = null;</script>

        <h4><label for="tags-input"><?php _e('Tags'?></label></h4>
        <div class="input-text-wrap">
            <input type="text" name="tags_input" id="tags-input" tabindex="3" value="<?php echo get_tags_to_edit$post->ID ); ?>" />
        </div>

        <p class="submit">
            <input type="hidden" name="action" id="quickpost-action" value="post-quickpress-save" />
            <input type="hidden" name="post_ID" value="<?php echo $post_ID?>" />
            <input type="hidden" name="post_type" value="post" />
            <?php wp_nonce_field('add-post'); ?>
            <?php submit_button__'Save Draft' ), 'button''save'false, array( 'id' => 'save-post''tabindex'=> ) ); ?>
            <input type="reset" value="<?php esc_attr_e'Reset' ); ?>" class="button" />
            <span id="publishing-action">
                <input type="submit" name="publish" id="publish" accesskey="p" tabindex="5" class="button-primary" value="<?php current_user_can('publish_posts') ? esc_attr_e('Publish') : esc_attr_e('Submit for Review'); ?>" />
                <img class="waiting" src="<?php echo esc_urladmin_url'images/wpspin_light.gif' ) ); ?>" alt="" />
            </span>
            <br class="clear" />
        </p>

    </form>

<?php
    
if ( $drafts )
        
wp_dashboard_recent_drafts$drafts );
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics