Skip to content

Instantly share code, notes, and snippets.

@Viper007Bond
Created September 30, 2011 00:14
Show Gist options
  • Save Viper007Bond/1252312 to your computer and use it in GitHub Desktop.
Save Viper007Bond/1252312 to your computer and use it in GitHub Desktop.
Private post_status in a List_Table
<?php
class Your_Media_List_Table extends WP_Media_List_Table {
/* some stuff here */
// Adds a WHERE modify filter, calls parent version of prepare_items(), then removes filter
function prepare_items() {
add_filter( 'posts_where', array( &$this, 'modify_post_status_to_private' ) );
parent::prepare_items();
remove_filter( 'posts_where', array( &$this, 'modify_post_status_to_private' ) );
}
// Changes the "post_status" WHERE value from "inherit" to "private"
function modify_post_status_to_private( $where ) {
return str_replace( "post_status = 'inherit' ", "post_status = 'private' ", $where );
}
/* more stuff here */
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment