| 1 | <?php
|
|---|
| 2 | /*
|
|---|
| 3 | Plugin Name: Example upload.php join filter
|
|---|
| 4 | Description: Breaks upload.php
|
|---|
| 5 | Author: Benjamin J. Balter
|
|---|
| 6 | Version: 1.0
|
|---|
| 7 | Author URI: http://ben.balter.com
|
|---|
| 8 | */
|
|---|
| 9 |
|
|---|
| 10 | function bb_filter_media_join( $join ) {
|
|---|
| 11 |
|
|---|
| 12 | $join .= ' LEFT OUTER JOIN wp_trunk_posts bb_post_parent ON bb_post_parent.ID = wp_trunk_posts.post_parent';
|
|---|
| 13 |
|
|---|
| 14 | return $join;
|
|---|
| 15 | }
|
|---|
| 16 |
|
|---|
| 17 | function bb_filter_media_where( $where ) {
|
|---|
| 18 |
|
|---|
| 19 | $where .= " AND ( bb_post_parent.post_type IS NULL OR bb_post_parent.post_type != 'page' )";
|
|---|
| 20 |
|
|---|
| 21 | return $where;
|
|---|
| 22 |
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | //media filters
|
|---|
| 26 | add_filter( 'posts_join_paged', array( &$this, 'bb_filter_media_join' ) );
|
|---|
| 27 | add_filter( 'posts_where_paged', array( &$this, 'bb_filter_media_where' ) );
|
|---|