<?php/*Plugin Name: GV Manage Posts EXPERIMENTALPlugin URI: http://simianuprising.com/Description: Modifies post management screens for moderation and elegant searching.Author: Jeremy ClarkeVersion: 0.1Author URI: http://simianuprising.com/*//////////////////////////////////// IMPORTANT NOTES//// - as of 2.3.1, the number of posts shown on the post management pages// is hardcoded into the edit.php file as 15. To have the draft manag-// ement page load fast you have to manually edit that page to a more // reasonable number. //// - There should be an option to remove the edit categories button from// the interface if you don't want it, lots of people won't want it. //// - Currently this plugin assumes you are running FWP and that you are// managing drafts, it should be modified to show normal post info // when the current post is not syndicated (and also display the diff). //// - Currently it just loads on the all versions of the edit post listing screen. // in the future it should be its own screen// or else take over for all edit.php screens (though it's more useful// for drafts, so calling them 'mass edit' or something and just listing// both all and draft in that form is probably a good idea.//// - Settings other than category should also be added, with options for// what to show and what to skip set by the user for the whole blog // (or for only drafts/published)function gv_add_draft_management() {add_submenu_page('feedwordpress/feedwordpress.php', 'Manage Drafts', 'Manage Drafts', 'publish_posts','edit.php?post_status=draft');add_management_page('Manage Drafts', 'Drafts', 'publish_posts', 'edit.php?post_status=draft');}add_action('admin_menu', 'gv_add_draft_management');add_filter('manage_posts_columns', 'gv_custom_columns');function gv_custom_columns($defaults) {// if ($_GET['post_status'] == 'draft') { unset($defaults['comments']); unset($defaults['id']); unset($defaults['title']); unset($defaults['id']); unset($defaults['author']); unset($defaults['date']); unset($defaults['modified']); unset($defaults['categories']); $defaults['preview'] = __('Preview'); $defaults['gv_manage_drafts'] = __('Status');// } return $defaults;}add_action('wp_print_scripts', 'gv_enqueue_scripts');function gv_enqueue_scripts() { if (is_admin()) { wp_enqueue_script('jquery'); wp_enqueue_script('gv_jquery_panels', get_bloginfo('template_url').'/js/jquery.slidepanel.js'); wp_enqueue_script('gv_jquery_panelspack', get_bloginfo('template_url').'/js/jquery.slidepanel.pack.js'); } }add_action('manage_posts_custom_column', 'gv_custom_column', 10, 2);function gv_custom_column($column_name, $id) { if( $column_name == 'gv_manage_drafts' ) { global $post, $checked_categories; //if ($post->post_status == 'draft') { // the dropdown categories need $post_id to be set, and it is // never set on this screen, so we set it then unset // it again to stay safe. $checked_categories = wp_get_post_categories($post->ID); // echor($checked_categories); // set up some js for each category section to have a trigger ?> <div id="gv-post-management-tools"> <script type="text/javascript"> $j=jQuery.noConflict(); $j(document).ready(function(){ $j("#gv-post-cats-toggle-<?php echo $post->ID;?>").click(function(){ $j("#gv-post-cats-<?php echo $post->ID;?>").slideToggle("slow"); return false; }); }); </script> <div class="status-<?php echo $post->post_status;?>"> <?php if ($post->post_status == 'publish'){ echo "Published"; } else { echo $post->post_status; }?> </div> <form action="#" method="post" id="gv-post-manage"> <div class="gv-post-cats-toggle" id="gv-post-cats-toggle-<?php echo $post->ID;?>"> Edit Categories </div> <div class="gv-post-cats" id="gv-post-cats-<?php echo $post->ID;?>"> <ul class="list:category categorychecklist form-no-clear"> <?php dropdown_categories(); ?> </ul> </div> <input type="hidden" name="gv_manage_post_id" id="gv_manage_post_id" value="<?php echo $id;?>" /> <?php if ($post->post_status != 'publish') { ?> <input type="submit" class="button" name="gv_publish_post" id="gv_publish_post" value="Publish" /> <?php } ?> <input type="submit" class="button" name="gv_save_post" id="gv_save_post" value="Save" /> </form> </div> <?php unset($post_id); //} } if( $column_name == 'preview' ) { global $post; //if ($post->post_status == 'draft') { echo '<div class="gv-post-preview">'; echo '<div class="gv-post-comments">'; echo $post->comment_count; echo "</div> \n"; echo '<h3><a href="'.get_post_meta($post->ID, 'syndication_permalink', true).'">'.$post->post_title."</a></h3> \n"; echo '<div class="gv-postmeta">'."\n"; echo '<div class="gv-post-id">ID '.$post->ID."</div> \n"; echo '<h4> Posted by: '.get_author_name($post->post_author)."</h4> \n"; echo '<h4> Categories: '; foreach (wp_get_post_categories($post->ID) as $categories => $category) { echo '<a href="'; echo get_category_link($category); echo '" title="link to the '; echo get_cat_name($category);echo ' category">';echo get_cat_name($category);echo "</a>, \n"; } echo '<h4>';the_date(); echo " - ";the_time();echo "</h4> \n"; echo "</div> \n"; if ($_GET['post_status'] == 'draft') { the_content(); } else { gv_display_manual_excerpt_admin(); } echo '</div>'; // } } }// add a management function only when we are in the admin. if (is_admin()) { add_action('init', 'gv_manage_posts');}function gv_manage_posts() { global $wpdb; //echor($_POST); if ($_POST['gv_manage_post_id']) : $old_post = get_post($_POST['gv_manage_post_id']); $guid = $old_post->guid; $id = $old_post->ID; $postarr = array(); $postarr['ID'] = $_POST['gv_manage_post_id']; if ($_POST['post_category']) $postarr['post_category'] = $_POST['post_category']; if ($_POST['gv_publish_post']) : $postarr['post_status'] = 'publish'; $postarr['post_date'] = current_time('mysql'); endif; if ($_POST['gv_reject_post']) : $postarr['post_status'] = 'pending'; $postarr['post_date'] = 0; endif; wp_update_post($postarr); // reset the guid to hte old one so FWP doesn't get confooooosad. $result = $wpdb->query(" UPDATE $wpdb->posts SET guid='$guid' WHERE ID='$id' "); endif; // end if gv_manage_post_id}// some temporary css definitions add_action('admin_head', 'gv_temp_admin_css');function gv_temp_admin_css() { ?> <style type="text/css"> body, td { vertical-align:top; } #the-list td { padding:10px; } #the-list td.alternate { padding-top:5px; } .gv-post-cats-toggle { border: 1px solid #aaa; color: #333; width:157px; padding: 3px 10px 3px 3px; margin: 10px 0 0 0; font-size:10pt; background: #E6E6E6 url(<?php bloginfo('template_url');?>/images/triangle.gif) no-repeat 153px; } .gv-post-cats { width:150px; height: 250px; border: 3px solid #aaa; border-width: 0px 1px 1px 1px; margin:0; overflow:auto; padding:10px; background:#fff; display:none; } #gv-post-manage .button { margin-top:10px; width:47%; } #gv-post-manage #gv_reject_post { width:98%; text-align:center; margin-top:30px; color: #bb0018; } .gv-post-cats ul, .gv-post-cats ul li { margin:0; padding:0; list-style:none; } .gv-post-cats ul ul { margin-left:15px; font-size:90%; font-color:#333; } .gv-post-preview { overflow:hidden; } .gv-post-preview h3{ margin:0; padding: 0px 0 0px 0; font-size:14pt; } .gv-post-preview h3 a { color:#333; border-bottom:none; } .gv-postmeta { color:#777; background:#f8f8f8; border:1px solid #ccc; border-width: 1px 0; padding: 5px 5px 4px 5px; margin: 5px 35px 10px 0; } .alternate .gv-postmeta { background:#fff; } .gv-postmeta h4 { font-weight:normal; padding:0px; margin: 0px 0 3px 0; } #gv-post-management-tools .status-publish { font-size:20pt; color: #506ebf; } #gv-post-management-tools .status-draft { font-size:20pt; color: #bb0018; } .gv-post-id { float:right; padding:5px; margin:0px 0 5px 5px; font-size:13pt; font-weight:bold; color:#fff; background:#ccc; } .alternate .gv-post-id { background:#fff; color:#bbb; } .gv-post-comments { float:right; padding:3px 16px 10px 0; margin: 0px 0 30px 10px; font-size:11pt; font-weight:bold; color:#bbb; text-align:right; background: url(<?php bloginfo('url')?>/wp-content/plugins/gv-manage-posts/comment.png) right top no-repeat; } h4.gv-aggregated { font-weight:bold; color:#555; clear:none; } .alternate .gv-post-comments { color:#999; }</style> <?php}// -----------------------------------------------------------------------------// Display a manual limited excerpt of post content//// For use inside the loop. Meant to replace the_excerpt in situations// where it may contain full text (e.g. aggregated posts with faulty excerpts)// function gv_display_manual_excerpt_admin($length='300') { global $post; $excerpt = strip_tags($post->post_content); $excerpt = substr($excerpt,0,$length).'...'; echo $excerpt; }?>