PHP Problem: Add Something To "Visit Site" Button In This Theme

PatPirate

New member
Dec 27, 2009
320
2
0
Hello,

so I wanted to change the code of a button that my theme generates automatically. Basically you just enter an URL in your post, and the plugin (called "WPReviewPlugin") on my site inserts it in the image of some kind of button.

I need to change this link to a cloaked, internal link, and for my webanalytics service Clicky to track these kinds of links, there has to be something added to it. This:

<a href="http://somecoolsite.com">Click here</a>

needs to be changed like this:
<a class="clicky_log_outbound" href="http://somecoolsite.com">Click here</a>

As the support of the plugin/theme is virtually nonexistent, I tried to do it myself, and found the file "wprevisitsite.php", which looks like this:

PHP:
<?php


$visitsite = get_option("newembed-visitsite"); // no, individual, all
$visitsitewhere = get_option("newembed-visitsitewhere"); // below, above, wprevisitsitebutton
$visitsitebutton = get_option("newembed-visitsitebutton");
$visitsitenewwindow = get_option('newembed-visitsitenewwindow');


if ($visitsitenewwindow == "Yes") {
    $target = "_blank";
} else {
    $target = "";
}

$visitsiteurl = get_post_meta($post->ID, "_affurl", true);

if ((string) $visitsiteurl != "") {         // no visitsiteurl

    $buttoncode = "<a href='".$visitsiteurl."' ".wpre_arewenofollow()." target='".$target."' class='btn-click-here'><img src='".get_bloginfo('url')."/wp-content/plugins/re/images/visitsite/".$visitsitebutton."' style='border: 0px;'></a>";
    echo $buttoncode;
This part:
PHP:
$buttoncode = "<a href='".$visitsiteurl."'
seemed to be the relevant part, so I changed it into this:

PHP:
$buttoncode = "<a class="clicky_log_outbound" href='".$visitsiteurl."'
which leads into this:
Parse error: syntax error, unexpected T_STRING in /home/blablabla/wp-content/themes/newreviewclean/wprevisitsite.php on line 20
OK, so I have no idea of php whatsoever, meaning I'm completely stuck. Has anyone an idea how to resolve this?
 


Code:
$buttoncode = "<a class='clicky_log_outbound' href='".$visitsiteurl."' ".wpre_arewenofollow()." target='".$target."' class='btn-click-here'><img src='".get_bloginfo('url')."/wp-content/plugins/re/images/visitsite/".$visitsitebutton."' style='border: 0px;'></a>";

Try that line? I think its because you are using double quotes around the class declaration..
 
  • Like
Reactions: PatPirate
Hey, thx, that works in a way, +rep given.
Only problem is that with this new code, the button changes it's position and umps from the top right (where it belongs) to directly below the post title. Any idea how to fix that?
 
Must be a css issue.. the PHP would not affect position.. have u got styles on ur 'clicky_log_outbound' class that are messing with the position??
 
Nope, no styles for that, or at least nothing that I can think off... This is something the theme makers probably didn't think off, so I can't see why they would set up especially for it. Have no idea on how this css stuff works anyway.
 
Forgot to mention: If someone would be willing to take a look at it, I would pay $20 to get this solved for me :)
 
Try this..


$follow = wpre_arewenofollow();

$bloginfo = get_bloginfo('url');
$imgsrc = "{$bloginfo}/wp-content/plugins/re/images/visitsite/{$visitsitebutton}";

$buttoncode = "<a href='{$visitsiteurl}' {$follow} target='{$target}' class='btn-click-here'><img src='{$imgsrc}' style='border: 0px;'></a>";

echo $buttoncode;
 
Did you manage to get it solved. I won't mind taking a look at it.

Add me on Skype, should you want.