pollpress_filter('posts_where'); $this->factory = new pollpress_poll_factory(); } function process($data) { // If they're looking for a specific post, allow that. Just don't list $num_matches_one = preg_match('/\s+ID\s*=\s*\d+/', $data); $num_matches_two = preg_match('/[\s+|\(]post_name\s*=\s*\'[^\']*\'[\s+|\)]/', $data); if ( ($num_matches_one > 0) || ($num_matches_two > 0) ) return $data; // Similarly, if they're looking in a specific category, allow it $num_matches = preg_match('/[\s+|\(]category_id\s*=\s*\'?\d+\'?[\s+|\)]/', $data); if ( $num_matches > 0 ) return $data; // Allow searches to go through $matches = array(); $num_matches = preg_match($this->search_regex, $data, $matches); if ( $num_matches > 0 ) return $this->inject_options_search_sql($data, $matches); // They're trying to list, so exclude Polls $poll_table = new pollpress_table_poll(); return $data . ' AND ' . $poll_table->get_exclude_polls_sql(); } function inject_options_search_sql($data, $matches) { $subquery = $this->factory->get_posts_with_text_sql( $matches[1] ); $segments = preg_split($this->search_regex, $data, 2); $data = $segments[0] . $matches[0] . ' OR (ID IN (' . $subquery . ')) ' . $segments[1]; return $data; } } ?>