From c95eb2da83422b9b51589c0f5dd94b90ed038093 Mon Sep 17 00:00:00 2001
From: Erick Hitter <ehitter@gmail.com>
Date: Sun, 21 Jul 2013 12:17:11 -0400
Subject: [PATCH] Attempt at using the native datetime picker for an end date,
 to reduce additional UI.

---
 eth-timeline.php | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/eth-timeline.php b/eth-timeline.php
index f0590ac..f68f646 100644
--- a/eth-timeline.php
+++ b/eth-timeline.php
@@ -57,6 +57,8 @@ class ETH_Timeline {
 	 */
 	private function setup() {
 		add_action( 'init', array( $this, 'action_init' ) );
+
+		add_action( 'post_submitbox_misc_actions', array( $this, 'metabox_end_date' ), 5 );
 		add_action( 'save_post', array( $this, 'action_save_post' ) );
 
 		add_filter( 'gettext', array( $this, 'filter_gettext' ) );
@@ -128,6 +130,34 @@ class ETH_Timeline {
 		// ) );
 	}
 
+	/**
+	 *
+	 */
+	public function metabox_end_date() {
+		$screen = get_current_screen();
+
+		if ( is_object( $screen ) && ! is_wp_error( $screen ) && $this->post_type == $screen->post_type )
+			$post_type_object = get_post_type_object( $screen->post_type );
+
+			// Borrowed from Core: http://core.trac.wordpress.org/browser/trunk/wp-admin/includes/meta-boxes.php?rev=24522#L153
+			$datef = __( 'M j, Y @ G:i' );
+
+			// Need to set these based on postmeta
+			$stamp = 'End:';
+			$date = null;
+			// $data = date_i18n( $datef, strtotime( current_time('mysql') ) );
+
+			if ( current_user_can( $post_type_object->cap->publish_posts ) ) : // Contributors don't get to choose the date of publish ?>
+			<div class="misc-pub-section endtime">
+				<span id="timestamp-end">
+				<?php printf($stamp, $date); ?></span>
+				<!-- <a href="#edit_timestamp_end" class="edit-timestamp-end hide-if-no-js"><?php _e('Edit') ?></a> -->
+				<div id="timestampdiv-end"><?php touch_time( ( $action == 'edit' ), 1, 1, true ); ?></div>
+			</div><?php // /misc-pub-section ?>
+		<?php endif; ?>
+		<?php
+	}
+
 	/**
 	 *
 	 */
-- 
GitLab