Make WordPress Core

Ticket #19779: example-filter.php

File example-filter.php, 676 bytes (added by benbalter, 15 years ago)

Example join filter to break upload.php (excluded media attached to pages)

Line 
1<?php
2/*
3Plugin Name: Example upload.php join filter
4Description: Breaks upload.php
5Author: Benjamin J. Balter
6Version: 1.0
7Author URI: http://ben.balter.com
8*/
9
10function 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
17function 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
26add_filter( 'posts_join_paged', array( &$this, 'bb_filter_media_join' ) );
27add_filter( 'posts_where_paged', array( &$this, 'bb_filter_media_where' ) );