go41

modification of WP SEO Tags plugin

von Joern am 23. Sep. 2010 | Keine Kommentare

I like to use this Plugin Name: WP SEO Tags ( Plugin URI: http://www.saquery.com/wordpress/wp-seo-tags ) to add Tag-Search-Page for each Keyword Phrase logged and moderated before they appear. The problem for me was an ever increasing table in my database (wpseotags_referer)

What to do to stop this? I added a function to delete items from this table which are marked as deleted and not used anymore.

I also added a function to stop logging but still have the plugin running to serve the ‚tags template‘
for WordPress users with advanced knowledge I just include my modified wp-seo-tags.php here.
Be careful, do not just replace the file with the original version!
There are changes in the DEFAULT CHARSET which is here utf8

and also changes in a FULLTEXT table where I changed (post_title,post_content) to (post_name,post_content)

to be compatible to a Plugin Name: ©Feed ( http://bueltge.de/wp-feed-plugin/204/ )
Additionally I do not use widgets, its removed.
the full modified code FOR ADVANCED USERS to take just what you need by comparing the files side by side:

<?php
/*
Plugin Name: WP SEO Tags
Plugin URI: http://www.saquery.com/wordpress/wp-seo-tags
Description: WP SEO Tags
Version: 2.2 edited by Joern
Author: Stephan Ahlf
Author URI: http://saquery.com
*/
global $wpseotags_preview;
$wpseotags_preview = false;
$wpdb->wpseotags_dbTable = $wpdb->prefix."wpseotags_referer";
$saqClickCheck_db_version = "0.1";

function saq_wpseotags_DBSetup() {
global $wpdb;
$sql="CREATE TABLE IF NOT EXISTS ".$wpdb->wpseotags_dbTable."(
q varchar(255) NOT NULL,
blogtarget varchar(255) NOT NULL,
target varchar(255) NOT NULL,
hits INT(11) NOT NULL default 1,
dt TIMESTAMP NOT NULL default CURRENT_TIMESTAMP,
moderated INT(1) NOT NULL default 0,
deleted INT(1) NOT NULL default 0,
engine varchar(255) NOT NULL,
PRIMARY KEY (q)
) ENGINE = MYISAM DEFAULT CHARSET=utf8";
require_once(ABSPATH . ‚wp-admin/includes/upgrade.php‘);
dbDelta($sql);

$wpdb->hide_errors();
$sql="CREATE FULLTEXT INDEX post_related ON ".$wpdb->posts."(post_name,post_content);";
$wpdb->query($sql);
$wpdb->show_errors();
}
if(isset($_GET[‚activate‘]) && $_GET[‚activate‘] == ‚true‘)
add_action(‚init‘, ’saq_wpseotags_DBSetup‘);

if (function_exists(‚load_plugin_textdomain‘)) {
if ( !defined(‚WP_PLUGIN_DIR‘) ) {
load_plugin_textdomain(‚wp-seo-tags‘, str_replace( ABSPATH, “, dirname(__FILE__) ));
} else {
load_plugin_textdomain(‚wp-seo-tags‘, false, dirname(plugin_basename(__FILE__)));
}
}
function saq_wpseotags_is_keyword() {
return (strtolower(substr($_SERVER["REQUEST_URI"], 1, 4))=="tags") ;
}

function saq_wpseotags_keywords_parseQuery() {
if (saq_wpseotags_is_keyword()) {
global $wp_query, $wpdb;
$wp_query->is_single = false;
$wp_query->is_page = false;
$wp_query->is_archive = false;
$wp_query->is_search = false;
$wp_query->is_home = false;
$arr = explode("/",strtolower($_SERVER["REQUEST_URI"]));
$keys = $arr[2];

$sql = "select count(*) from ".$wpdb->wpseotags_dbTable." where target = ‚$keys‘ and moderated = 1 and deleted = 0";
$cnt=$wpdb->get_var($sql);

if ($cnt>0 || current_user_can(‚edit_users‘)){
if($cnt==0)$wp_query->saq_wpseotags_preview=true;
$wp_query->is_search = true;
add_action(‚template_redirect‘, ’saq_wpseotags_keywords_includeTemplate‘);
}
}
}

function saq_wpseotags_keywords_includeTemplate() {
if (saq_wpseotags_is_keyword()) {
//add_filter(‚wp_title‘, ’saq_wpseotags_title‘);
add_filter(‚the_title‘, ’saq_wpseotags_title‘);
//add_filter(‚wp_footer‘, ’saq_wpseotags_add_footer‘);
$template = TEMPLATEPATH . "/wp-seo-tags-template.php";
load_template($template);
exit;
}
return;
}

function saq_wpseotags_title(){
global $searchphrase, $blogname;
$result = str_replace("%blogname%",get_bloginfo(’name‘),saq_(‚Search for %searchphrase% on %blogname%‘));
$result = str_replace("%searchphrase%",saq_wpseotags_getTitleKeyWords(),$result);
$result = urldecode($result);
remove_filter(‚the_title‘, ’saq_wpseotags_title‘);
return $result;
}

function seo_tags_drop_deleted()
{
global $wpdb;
$wpdb->query("DELETE FROM ".$wpdb->wpseotags_dbTable." WHERE deleted = 1");
}

function saq_wpseotags_logSearchEngineQuery(){
global $wpdb;

$engines[‚google.‘] = ‚q=‘;
$engines[‚altavista.com‘] = ‚q=‘;
$engines[’search.msn.‘] = ‚q=‘;
$engines[‚yahoo.‘] = ‚p=‘;
$engines[‚bing.‘] = ‚q=‘;
$engines[‚yandex.‘] = ‚text=‘;

$referer = $_SERVER[‚HTTP_REFERER‘];
$blogtarget = $_SERVER["REQUEST_URI"];
$ref_arr = parse_url("$referer");
$ref_host = $ref_arr[‚host‘];

foreach($engines as $host => $skey){
if (strpos($ref_host, $host) !== false){

$res_query = urldecode($ref_arr[‚query‘]);
if (preg_match("/{$engines[$host]}(.*?)&/si",$res_query."&",$matches)){
$query = trim($matches[1]);
$query = str_replace(‚+‘, ‚-‚, $query);
$target = str_replace("’","“",str_replace(";","",sanitize_title_with_dashes($query)));
$sql= "insert into ".$wpdb->wpseotags_dbTable.
"(q, blogtarget, target,engine) VALUES (‚$query‘, ‚$blogtarget‘,’$target‘, ‚$ref_host‘) ON duplicate KEY UPDATE hits=hits+1, DT=CURRENT_TIMESTAMP";
$msg="SearchEngineRedirect successful logged.";
try {
$result = $wpdb->query($sql);
$sql = "select count(*) from ".$wpdb->wpseotags_dbTable." where moderated = 1 and target = ‚$target’";
$cnt=$wpdb->get_var($sql);
if ($cnt>0){
$sql = "update ".$wpdb->wpseotags_dbTable." set moderated = 1 where moderated = 0 and target = ‚$target’";
$result = $wpdb->query($sql);
}
$sql = "select count(*) from ".$wpdb->wpseotags_dbTable." where deleted = 1 and target = ‚$target’";
$cnt=$wpdb->get_var($sql);
if ($cnt>0){
$sql = "update ".$wpdb->wpseotags_dbTable." set deleted = 1 where deleted = 0 and target = ‚$target’";
$result = $wpdb->query($sql);
}
} catch (Exception $e) {
$msg=$e->getMessage();
}
echo "n<!– WP SEO Tags : $parm ; http://saquery.com/wp-seo-tags/ –>n" ;
}
break;
}
}
}

function saq_wpseotags_add_meta(){
if (saq_wpseotags_is_keyword()) {
echo "n<!– WP SEO Tags – http://www.saquery.com/ –>" .
"n<meta name="keywords" content="" . urldecode(saq_wpseotags_getMetaKeyWords()) . "" />".
"n<link rel="canonical" href="".get_bloginfo(‚url‘)."/tags/".saq_wpseotags_getMetaKeyWords("-")."/" />".
"n<!– // WP SEO Tags –>n";
}

if (get_option(’seotags_logging‘) == "1")
{
saq_wpseotags_logSearchEngineQuery(); echo "<!– logging enabled –>";
} else {
echo "<!– logging disabled –>";
}

}

add_action(‚wp_head‘, ’saq_wpseotags_add_meta‘, 0);

//print_radd_cacheaction("add_cacheaction", "saq_wpseotags_add_meta");

function saq_keywords_createRewriteRules($rewrite) {
global $wp_rewrite;

$KEYWORDS_QUERYVAR = "tags";
// add rewrite tokens
$keytag_token = ‚%‘ . $KEYWORDS_QUERYVAR . ‚%‘;
$wp_rewrite->add_rewrite_tag($keytag_token, ‚(.+)‘, $KEYWORDS_QUERYVAR . ‚=‘);

$keywords_structure = $wp_rewrite->root . $KEYWORDS_QUERYVAR . "/$keytag_token";
$keywords_rewrite = $wp_rewrite->generate_rewrite_rules($keywords_structure);
try {
//print_r($rewrite );
if ( gettype($rewrite) == "array" && gettype($keywords_rewrite) == "array" ) {
return ( $rewrite + $keywords_rewrite );
} else {
return $rewrite;
}
// return array_merge($rewrite,$keywords_rewrite);
} catch (Exception $e) {
}
}
add_action(‚parse_query‘, ’saq_wpseotags_keywords_parseQuery‘);
add_filter(‚generate_rewrite_rules‘, ’saq_keywords_createRewriteRules‘);

function saq_($txt){
return __($txt,’wp-seo-tags‘);
}
function saq_wpseotags_adminoptions1(){
global $wpdb;

if ($_POST[‚delete‘]){
$sql= "update ".$wpdb->wpseotags_dbTable." set deleted = 1 where target in "."(‚".implode("‘,’",array_keys($_POST))."‘)";
$res = $wpdb->get_results($sql);
}
if ($_POST[‚unmoderate‘]){
$sql= "update ".$wpdb->wpseotags_dbTable." set moderated = 0 where target in "."(‚".implode("‘,’",array_keys($_POST))."‘)";
$res = $wpdb->get_results($sql);
}
if ($_POST[‚undelete‘]){
$sql= "update ".$wpdb->wpseotags_dbTable." set deleted = 0 where target in "."(‚".implode("‘,’",array_keys($_POST))."‘)";
$res = $wpdb->get_results($sql);
}
if ($_POST[’submit‘]){
$sql= "update ".$wpdb->wpseotags_dbTable." set moderated = 1 where target in "."(‚".implode("‘,’",array_keys($_POST))."‘)";
$res = $wpdb->get_results($sql);
}

if(isset($_POST[’seo_tags_options_submit‘])){
update_option(’seotags_logging‘, $_POST[’seotags_logging‘]);
echo ‚<div class="updated"><p><strong>Options saved</strong></p></div>‘;
}

if(isset($_POST[’seo_tags_delete_deleted‘]))
{
seo_tags_drop_deleted();
echo ‚<div class="updated"><p><strong>deleted items removed from database</strong></p></div>‘;
}

echo
‚<script>
function CkAllNone(obj,id){
var _a=document.getElementById(id).getElementsByTagName("INPUT");
for (var i=0;i<_a.length;i++) _a[i].checked=obj.checked;
}
</script>‘;
$where = "where deleted = 0 and moderated = 0";

if ($_POST[’showmoderated‘]){
$where = "where deleted = 0 and moderated=1";
}
if ($_POST[’showdeleted‘]){
$where = "where deleted = 1";
}
if ($_POST["saq_txt_the_filter"]){
$where .= " and target like ‚%".$_POST["saq_txt_the_filter"]."%’";
}

$query = "SELECT target, moderated, deleted, max(dt) as dt from ".$wpdb->wpseotags_dbTable ." $where group by target, moderated, deleted order by moderated asc, dt desc";
$res = $wpdb->get_results($query);
echo ‚<div name="top" id="icon-tools" class="icon32"><br /></div>
<h2>‘.saq_(‚Moderate incoming searchengine keywords‘).'</h2>
<div class="form-wrap">
<p><strong>‘.saq_(‚Tip‘).‘:</strong><br />‘.saq_(‚You can check if new incoming search queries deliver results in WP SEO Tag Search. Only Keyswords with a length of more than 3 letters will be considered‘).‘.</p>
<p><strong>In Sidebar limit is 20, results limited to 10 – JW</strong></p>‘;
?>
<form id="seo_tags_options" method="post" action="">
<table class="optiontable">
<tr>

<td><?php if (get_option(’seotags_logging‘))$checked=’checked="checked"‘; else $checked=“; ?>
<input class="checkbox" id="seotags_logging" name="seotags_logging" type="checkbox" value="1" <?php echo $checked; ?> />
</td>
<th scope="row">Check to Enable Logging</th>
</tr>
</table>

<p class="submit">
<input name="seo_tags_options_submit" value="Save Logging Option" type="submit" onclick="javascript:return(confirm(‚Are you sure to save optins?‘))">
This will save the logging option, disabled logging will not save new searches! <?php if (get_option(’seotags_logging‘) == "1") { echo "<strong>logging is currently enabled</strong>";} else { echo "<strong>logging is disabled</strong>";} ?>
</p>
<p class="submit">
<input name="seo_tags_delete_deleted" value="Remove ‚deleted‘ from Db" type="submit" onclick="javascript:return(confirm(‚Are you sure to delete all items marked DELETED?‘))">
This will delete all items marked ‚Deleted‘!
</p>
</form>
<?php
echo "<form id="frm_wpseo" action="" method="post">";
echo "<input type="checkbox" onclick="CkAllNone(this,’frm_wpseo‘);" />".saq_(‚Select all items in list‘).".";
echo "<hr /><table class="form-table" cellspacing="10" cellpadding="10">";
echo "<tr><th>".saq_(‚Selection‘)."</th>";
echo "<th>URL</th>";
echo "<th>".saq_(‚Last Searchengine Visitor‘)."</th>";
echo "<th>".saq_(‚Moderated‘)."</th>";
echo "<th>".saq_(‚Deleted‘)."</th>";
echo "</tr>";
foreach($res as $row) {
echo "<tr>";
echo "<td><input type="checkbox" name="$row->target" value="1" /></td>";
$lnk = "<a title="Test new WP SEO Tag Search URL…" href="".get_bloginfo(‚url‘)."/tags/".$row->target."" target="_blank">$row->target</a>";
/*My*/
$lnk = urldecode($lnk);
echo "<td>$lnk</td>";
echo "<td>".$row->dt."</td>";
if ($row->moderated==1){
$chk = "<input type="checkbox" disabled="disabled" checked="checked" />";
} else {
$chk = "<input type="checkbox" disabled="disabled" />";
}
echo "<td>$chk</td>";
if ($row->deleted==1){
$chk = "<input type="checkbox" disabled="disabled" checked="checked" />";
} else {
$chk = "<input type="checkbox" disabled="disabled" />";
}
echo "<td>$chk</td>";
echo "</tr>";
}
$_btn = "<input type="submit" style="width:170px;"";
$_txt = "<input type="text" style="width:130px;"";
$delim=" » ";
echo "</table><hr />";
echo "$_btn name="submit" value="".saq_(‚Moderate‘)."" onclick="return confirm(‚".saq_(‚Mark selected URLs as moderated now‘)."?‘);" />$delim";
echo "$_btn name="delete" value="".saq_(‚Delete‘)."" onclick="return confirm(‚".saq_(‚Mark selected URLs as deleted now‘)."?‘);" />$delim";
echo "$_btn name="unmoderate" value="".saq_(‚Remove moderation‘)."" onclick="return confirm(‚".saq_(‚Mark selected URLs as unmoderated now‘)."?‘);" />$delim";
echo "$_btn name="undelete" value="".saq_(‚Undelete‘)."" onclick="return confirm(‚".saq_(‚Undelete selected URLs now‘)."?‘);" />";
echo "<hr />";
echo "$_btn name="refresh" value="".saq_(‚Show unmoderated‘)."" />$delim";
echo "$_btn name="showmoderated" value="".saq_(‚Show moderated‘)."" onclick="return confirm(‚".saq_(‚Show all moderated URLs now‘)."?‘);" />$delim";
echo "$_btn name="showdeleted" value="".saq_(‚Show deleted‘)."" onclick="return confirm(‚".saq_(‚Show all deleted URLs now‘)."?‘);" />$delim";
echo "Url-Text-Filter:$delim";
echo "$_txt name="saq_txt_the_filter" name="saq_txt_the_filter"";
if ($_POST["saq_txt_the_filter"]) echo " value="".$_POST["saq_txt_the_filter"].""";
echo " />";
echo "</form>";

echo ‚</div></div>‘;
}

function saq_wpseotags_admin_menu(){
add_submenu_page(‚options-general.php‘, ‚WP SEO Tags options‘, ‚WP SEO Tags‘, 8, __FILE__, ’saq_wpseotags_adminoptions1′);
}

add_action(‚admin_menu‘, ’saq_wpseotags_admin_menu‘);

function saq_array_insert(&$array, $insert, $position = -1) {
$position = ($position == -1) ? (count($array)) : $position ;
if($position != (count($array))) {
$ta = $array;
for($i = $position; $i < (count($array)); $i++) {
if(!isset($array[$i]))die();
$tmp[$i+1] = $array[$i];
unset($ta[$i]);
}
$ta[$position] = $insert;
$array = $ta + $tmp;
} else {
$array[$position] = $insert;
}

ksort($array);
return true;
}

function saq_wpseotags_strArrayFilter($val){
return (strlen($val)>2);
}

function saq_wpseotags_getMetaKeyWords($delimiter=",", $maxKeywordLength=-1){
$arr = explode("/",strtolower($_SERVER["REQUEST_URI"]));
$result=null;
if ($maxKeywordLength==-1){
$result=str_replace("-",$delimiter,$arr[2]);
} else {
$keys = explode("-",$arr[2]);
$keys = array_filter($keys, "saq_wpseotags_strArrayFilter");
$result = implode($delimiter, $keys);
}
return $result;
}
function saq_wpseotags_getTitleKeyWords(){
$result="";
$_orWord = saq_(‚or‘);
$keys = explode(",",saq_wpseotags_getMetaKeyWords(",",3));//explode("-", $arr[2]);
if (count($keys)>1) saq_array_insert($keys, $_orWord, count($keys)-1);
foreach($keys as $item){
if ($item!=$_orWord) $item = ucfirst($item);
$result .= $item." ";
}
return trim($result);
}

function saq_wpseotags_sortByLength($a,$b){
if($a == $b) return 0;

return (count(explode(" ",$a)) > count(explode(" ",$b)) ? -1 : 1);
}

function saq_wpseotags_permutations($end, $start = 0){
if($start == $end)return array(array($end));
if($start > $end)list($start, $end) = array($end, $start);
$rtn = array(array($start));
for($i = $start + 1; $i <= $end; $i++){
$temp = array();
foreach($rtn as $k => $v) for($j = 0; $j <= count($v); $j++)$temp[] = saq_wpseotags_array__insert($v, $i, $j);
$rtn = $temp;
}
return array_reverse($rtn);
}

function saq_wpseotags_array__insert($array, $num, $pos){
foreach($array as $k => $v){
if($k == $pos)$rtn[] = $num;
$rtn[] = $v;
}
if($k < $pos) $rtn[] = $num;
return $rtn;
}

function saq_wpseotags_word_strings($in){
$words = preg_split(‚/s+/‘, $in);
$perms = saq_wpseotags_permutations(($c = count($words)) – 1);
$code = ‚foreach($perms as $v)$rtn[] = implode(" ", array(‚;
$comma = “;
for($i = 0; $i < $c; $i++){
$code .= $comma.’$words[$v[‚.$i.‘]]‘;
$comma =‘,‘;
}
$code .= ‚));‘;
eval($code);
return $rtn;
}

function saq_wpseotags_keyWordCombo($array){
$results = array(array());
foreach ($array as $element)
foreach ($results as $combination)
array_push($results,array_merge(array($element),$combination));
$p = array();
foreach($results as $combo) if (implode(" ", $combo)!="") array_push($p, implode(" ", $combo)) ;

$r = array();
foreach ($p as $i1) {
// array_push($r, $i1);
$k = saq_wpseotags_word_strings($i1);
foreach($k as $i2) array_push($r, $i2);
}

usort($r,"saq_wpseotags_sortByLength");
return $r;

}

//ob_start();

function saq_wpseotags_the_excerpt($txt, $keys, $permaLink){
$result = $txt;
//FB::info($txt);
//FB::info($keys);
//FB::info($permaLink);
//FB::info("——————");
for($i = 0; $i < count($keys); $i++){
$hits=0;
$key=trim($keys[$i]);
$replace = "<a href="".$permaLink."">".$key."</a>";
preg_match_all(‚#[^>]+(?=<[^/])|[^>]+$#‘, $result, $matches, PREG_SET_ORDER);
foreach ($matches as $val) {
$result = str_ireplace($val[0],str_ireplace($key,$replace,$val[0]),$result);
$hits = $hits+1;
}
}
//if (strlen($result)>300) $result = substr(0,200,$result);
return $result;
}

function getFadedColor($pCol, $pPercentage) {
$pPercentage = 100 – $pPercentage;
$rgbValues = array_map( ‚hexDec‘, str_split( ltrim($pCol, ‚#‘), 2 ) );

for ($i = 0, $len = count($rgbValues); $i < $len; $i++) {
$rgbValues[$i] = decHex( floor($rgbValues[$i] + (255 – $rgbValues[$i]) * ($pPercentage / 100) ) );
}

return ‚#‘.implode(“, $rgbValues);
}

function saq_wpseotags_getSqlQuery($keys, $boolKeys, $allwaysIncludeTarget){
global $wpdb;
$s=" SELECT *,
MATCH (
post_name, post_content
)
AGAINST (
‚".$keys."‘
) AS relevance
FROM ".$wpdb->posts."
WHERE
(post_status = ‚publish‘
AND MATCH (
post_name, post_content
)
AGAINST (
‚".$keys."‘
IN BOOLEAN
MODE
))";

if ($allwaysIncludeTarget) $s=$s." or post_name=’".saq_wpseotags_getMetaKeyWords(‚-‚)."’";
$s=$s." HAVING relevance > 0.1
ORDER BY relevance DESC
LIMIT 0 , 10";

return $s;
}

function saq_wpseotags_getpost($r,$id){
reset($r);
while (list($key, $post) = each($r)) if ($post->ID==$id) return $post;
}

function saq_wpseotags_printRealtedPosts(){
//error_reporting(0);
global $wpdb,$wp_query;
$keys = str_replace(";","",str_replace("’","“",saq_wpseotags_getMetaKeyWords(" ",3)));
$keys1 = "+".str_replace(",",", +",$keys);

$sql2 = saq_wpseotags_getSqlQuery($keys, """.$keys.""", false);
$res = $wpdb->get_results($sql2);
// $wpdb->show_errors();
if (!$res){
$sql2 = saq_wpseotags_getSqlQuery($keys, $keys1, false);
$res = $wpdb->get_results($sql2);
if (!$res){
$keys1 = trim(str_replace("+","",$keys1));
$sql2 = saq_wpseotags_getSqlQuery($keys, $keys1, true);
$res = $wpdb->get_results($sql2);
}
}

// print_r($sql2);
$res2=array();
$_res=array();
$maxScore=null;
foreach ($res as $row){
if ($maxScore==null) $maxScore=$row->relevance;
$res2[$row->ID]=($row->relevance/$maxScore)*100;
$_res[$row->ID] = $row->ID;
}

$posts=implode(",",array_keys($res2));

$_ids=implode(",",$_res);
//print_r($_ids);
/*
*/
$resultByTextSearch=null;
if ($posts) {
$args = array(
’numberposts‘ => 10,
‚include‘ => $_ids
);
$resultByTextSearch = get_posts($args);
} else {
$posts = query_posts( array( ‚post__in‘ => $res_2 ) );
}

if (!$resultByTextSearch){
$args = array(
’numberposts‘ => 10,
‚orderby‘ => ‚date‘,
‚tag’=> saq_wpseotags_getMetaKeyWords()
);
$attachments = get_posts($args);
}

$printed = array();
$arr = explode("/",strtolower($_SERVER["REQUEST_URI"]));
if ($arr[1]=="tags"){
$keys=explode("-", $arr[2]);
$_keys = array_filter($keys, "saq_wpseotags_strArrayFilter");
usort($_keys,"saq_wpseotags_sortByLength");
$_keys = array_unique($_keys);
$_keys = saq_wpseotags_keyWordCombo(array_slice($_keys, 0, 5));

$t=saq_wpseotags_getTitleKeyWords();
$txt = str_replace("%URI%",get_bloginfo(‚url‘)."/tags/$arr[2]/", saq_("This is only a Preview! %URI% is not moderated! You can view this page because you have an administrative userrole"));
if ($wp_query->saq_wpseotags_preview) echo "<i><p style="padding:5px;background:black;color:red"><strong>$txt</strong></p></i>";

$t=str_replace("%searchphrase%",$t, saq_(‚Looking for %searchphrase%‘));
/*My*/
$t=urldecode($t);
echo "<h2>".$t."?</h2>";
echo "<h3>".saq_(‚We have the following articles on these keywords for you‘)."…</h3>";

global $post;
//print_r($_keys);
if ($resultByTextSearch) foreach ($_res as $POST_ID) {

$post = saq_wpseotags_getpost($resultByTextSearch, $POST_ID);
setup_postdata($post);

$defaultColor = getFadedColor("#6666FF", 10);

if (!$printed[$post->ID] && $res2[$post->ID]>0){
$permaLink = get_permalink();//get_permalink($post->ID);
echo "n<h3>";
echo "<a ";
if ($res2[$post->ID]==100) echo "style="display:block;color:red;background:".$defaultColor."" ";
echo "href="";the_permalink();echo "">";the_title();echo "</a>";
echo "</h3>n";
//echo $post->ID;
if ($res2[$post->ID]==100) {
echo "n<p style="background:".$defaultColor."">";
} else {
echo "n<p>";
};

echo saq_wpseotags_the_excerpt(get_the_excerpt(), $_keys, $permaLink) ;
echo "</p>n";
echo ‚<p style="‘;
if ($res2[$post->ID]==100) {
echo ‚font:bold;color:red;background:‘.$defaultColor.‘;‘;
} else {
echo ‚background:‘.getFadedColor("#CCCCFF", $res2[$post->ID]).‘;‘;
};
echo ‚font-size:xx-small;font-weight:bold;">Relevanz: ‚. number_format($res2[$post->ID],2).’%</p>‘;
echo "<hr />";
$printed[$post->ID]=true;
}
}

if ($attachments) foreach ($attachments as $post) {
if (!$printed[$post->ID]){
setup_postdata($post);
echo "<h3>";
echo "<a href="".get_permalink()."">";the_title();echo "</a>";
echo "</h3>";
echo saq_wpseotags_the_excerpt(the_excerpt(), $_keys, get_permalink());
echo "<br /><hr />";
$printed[$post->ID]=true;
}
}

$w = "target like ‚%".str_replace(" " , "%‘ or target like ‚%", str_replace(";","",str_replace("’","“",saq_wpseotags_getMetaKeyWords(" ",3))))."%’";
$sql = "SELECT * FROM ".$wpdb->wpseotags_dbTable." WHERE target <> ‚".saq_wpseotags_getMetaKeyWords("-")."‘ and ($w) and moderated = 1 and deleted = 0
order by hits desc, dt desc
LIMIT 0 , 6";

echo "n<h3>Relevante Ergebnisse:</h3>";
$res = $wpdb->get_results($sql);
if ($res) {
echo "n<ul>";
foreach ($res as $row){
echo "n<li>";
echo "<a href="".get_bloginfo(‚url‘)."/tags/".$row->target."/" target="_self" title="".htmlspecialchars($row->q)."" >".htmlspecialchars($row->q)."</a> (".$row->hits." hits)";
echo "</li>";
}
echo "</ul><hr />";
}
}
}

//widget was here

// manual no widget
function wpseotags_widget() {
global $wpdb;
$sql=" SELECT * FROM ".$wpdb->wpseotags_dbTable." WHERE moderated = 1 AND deleted = 0 ORDER BY RAND() LIMIT 0 , 20";
$rows=$wpdb->get_results($sql);
foreach($rows as $row){
$t="Via ".str_replace("www.", "", htmlspecialchars($row->engine));
$a = "<a title="".htmlspecialchars($row->q)."" href="".get_bloginfo(‚url‘)."/tags/".$row->target."/">".urldecode(htmlspecialchars($row->q))."</a>";
echo "n<li>$a</li>";
}

} ;
?>
____________________
you find me on Google+, Twitter and Facebook

(von: Joern)

Sorry, no posts matched your criteria.

Autor:

Du findest mich auch auf Twitter und Facebook!

Schreibe einen Kommentar

Pflichtfelder sind mit * markiert.


Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.

weitere forum Beiträge: