Make WordPress Core

Ticket #33969: 33969.diff

File 33969.diff, 3.5 KB (added by erayalakese, 9 years ago)
  • wp-admin/includes/meta-boxes.php

    From 4467d500c3b946e71e9a2b46c040951853583ae6 Mon Sep 17 00:00:00 2001
    From: Eray Alakese <erayalakese@gmail.com>
    Date: Tue, 22 Sep 2015 21:52:48 +0300
    Subject: [PATCH] Publish Now feature for scheduled posts
    
    ---
     wp-admin/includes/meta-boxes.php |  2 +-
     wp-admin/post.php                | 15 +++++++++++++++
     wp-includes/link-template.php    | 34 ++++++++++++++++++++++++++++++++++
     3 files changed, 50 insertions(+), 1 deletion(-)
    
    diff --git a/wp-admin/includes/meta-boxes.php b/wp-admin/includes/meta-boxes.php
    index 5adfdba..a1f1c72 100644
    a b if ( ! empty( $args['args']['revisions_count'] ) ) : 
    193193if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
    194194<div class="misc-pub-section curtime misc-pub-curtime">
    195195        <span id="timestamp">
    196         <?php printf($stamp, $date); ?></span>
     196        <?php printf($stamp, $date); ?><?php if($post->post_status == 'future'): ?><a class="button button-small" href="<?php echo get_publishnow_post_link($post->ID); ?>"><?php echo __('Publish Now'); ?></a><?php endif; ?></span>
    197197        <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit date and time' ); ?></span></a>
    198198        <fieldset id="timestampdiv" class="hide-if-js">
    199199        <legend class="screen-reader-text"><?php _e( 'Date and time' ); ?></legend>
  • wp-admin/post.php

    diff --git a/wp-admin/post.php b/wp-admin/post.php
    index ba43eb1..1a91342 100644
    a b case 'trash': 
    224224        wp_redirect( add_query_arg( array('trashed' => 1, 'ids' => $post_id), $sendback ) );
    225225        exit();
    226226
     227case 'publishnow':
     228
     229        if ( ! $post )
     230                wp_die( __( 'The item you are trying to move to the Trash no longer exists.' ) );
     231
     232        if ( ! $post_type_object )
     233                wp_die( __( 'Unknown post type.' ) );
     234
     235        if ( ! current_user_can( 'publish_post', $post_id ) )
     236                wp_die( __( 'You are not allowed to publish this post.' ) );
     237
     238        wp_publish_post( $post_id );
     239        wp_redirect( add_query_arg( array('action' => 'edit', 'post' => $post_id), "post.php" ) );
     240        exit();
     241
    227242case 'untrash':
    228243        check_admin_referer('untrash-post_' . $post_id);
    229244
  • wp-includes/link-template.php

    diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php
    index 85b43c7..a51d996 100644
    a b function get_delete_post_link( $id = 0, $deprecated = '', $force_delete = false 
    13471347}
    13481348
    13491349/**
     1350 * Retrieve publish now link for post.
     1351 *
     1352 * @param int    $id           Post ID.
     1353 * @return string|void The 'publish now' post link URL for the given post.
     1354 */
     1355function get_publishnow_post_link( $id = 0 ) {
     1356
     1357        if ( !$post = get_post( $id ) )
     1358                return;
     1359
     1360        $post_type_object = get_post_type_object( $post->post_type );
     1361        if ( !$post_type_object )
     1362                return;
     1363
     1364        if ( !current_user_can( 'publish_post', $post->ID ) )
     1365                return;
     1366
     1367        $action = 'publishnow';
     1368
     1369        $delete_link = add_query_arg( 'action', $action, admin_url( sprintf( $post_type_object->_edit_link, $post->ID ) ) );
     1370
     1371        /**
     1372         * Filter the post delete link.
     1373         *
     1374         * @since 2.9.0
     1375         *
     1376         * @param string $link         The delete link.
     1377         * @param int    $post_id      Post ID.
     1378         * @param bool   $force_delete Whether to bypass the trash and force deletion. Default false.
     1379         */
     1380        return apply_filters( 'get_publishnow_post_link', wp_nonce_url( $delete_link, "$action-post_{$post->ID}" ), $post->ID );
     1381}
     1382
     1383/**
    13501384 * Retrieve edit comment link.
    13511385 *
    13521386 * @since 2.3.0