Help writing plugin to change date/time on Manage Posts
-
WordPress 2.5 does not show the exact time a post was published in the Manage Posts page, like older versions did. For those of us who future post, seeing the time a post goes live is crucial so we can avoid putting posts too close together. It’s very annoying having to open each post to see what time it’s set for.
So I’m trying to write a plugin, only I’ve never written one before and am finding tutorials only help so much.
What the plugin needs to do is replace lines 47 – 72 in /wp-admin/edit-post-rows.php:
case 'date': if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) { $t_time = $h_time = __('Unpublished'); } else { if ( 'modified' == $column_name ) { $t_time = get_the_modified_time(__('Y/m/d g:i:s A')); $m_time = $post->post_modified; $time = get_post_modified_time('G', true); } else { $t_time = get_the_time(__('Y/m/d g:i:s A')); $m_time = $post->post_date; $time = get_post_time('G', true); } if ( ( abs(time() - $time) ) < 86400 ) { if ( ( 'future' == $post->post_status) ) $h_time = sprintf( __('%s from now'), human_time_diff( $time ) ); else $h_time = sprintf( __('%s ago'), human_time_diff( $time ) ); } else { $h_time = mysql2date(__('Y/m/d'), $m_time); } } ?> <td><abbr title="<?php echo $t_time ?>"><?php echo $h_time ?></abbr></td> <?php break;
with
case 'date': ?> <td><?php if ( '0000-00-00 00:00:00' ==$post->post_date) _e('Unpublished'); else the_time(__('Y-m-d \<\b\r \/\> g:i:s a')); ?></td> <?php break;
I changed that in my actual edit-rows-post.php file, and it works.
The plugin I’ve attempted to write is this:
<?php if (!class_exists("ShowDateManagePosts")) { class ShowDateManagePosts { function ShowDateManagePosts() { //constructor } function showOldDate($h_time = '') { $h_time .= "mysql2date(__('Y/m/d \<\b\r \/\> g:i A'), $m_time);"; return $h_time; } } } //End Class ShowDateManagePosts if (class_exists("ShowDateManagePosts")) { $sd_manageposts = new ShowDateManagePosts(); } //Actions and Filters if (isset($sd_manageposts)) { //Actions add_action('restrict_manage_posts', array(&$ShowDateManagePosts, 'showOldDate'), 1); } ?>
At one point in editing, it was actually replacing the “countdown” style dates with the old style dates, but it wasn’t showing the times. And there was a syntax error, so I edited some more and now it’s doing nothing and returning this error:
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'Array' was given in /home/bohemian/public_html/wp-includes/plugin.php on line 311
Am I even barking up the right tree?
- The topic ‘Help writing plugin to change date/time on Manage Posts’ is closed to new replies.