How to make automatic safelink on the main self-hosted WordPress blog

Let’s make automatic safelink on main self-hosted wordpress blog. As a result it will be possible to use safelink tool in wordpress blogs. So today we will make a safelink blog in wordpress blog.

For this tutorial you have add some javascript codes in root html. besides some technical skill will be needed. But the process is not complex. That means you just have to put right codes in right place. That’s it!

How to make safelink on main wordpress blog - Webmasters Blogging Pedia

Check out how to make safelink on Blogger.

How to make Saflink in self-hosted WordPress blog : Step by Step Tutorial

1. Create and publish a new page on the website that you want to safelink, leave it blank first.

2. Copy the code below and place it in the HTML Template [location:  Wp-Admin > Appearance > Editor > Theme Header (header.php) or  Access Edit Template through CPanel] above the code </head> and edit and replace the url “http://your-website.com/safelink.html” with the  link page  that you created earlier, “Save” Template.

<script type = 'text / javascript'>
// <! [CDATA [
var blog = document.location.hostname;
var slug = document.location.pathname;
var ctld = blog.substr (blog.lastIndexOf ("."));
var currentURL = location.href;
var str = currentURL;
var res = str.replace ("http://your-website.com/safelink.html?url=", "");
$ (". Visit_Link"). Hide ();
function changeLink () {
var decodedString = Base64.decode (res);
window.open (decodedString, '_ self')
}

function generate () {
var linkDL = document.getElementById ("download"),
linkAL = document.getElementById ("download2"),
btn = document.getElementById ("btn"),
notif = document.getElementById ("daplong"),
directlink = document.getElementById ("download"). href,
time = 4;
var text_waktu = document.createElement ("span");
linkDL.parentNode.replaceChild (time_text, linkDL);
var id;
id = setInterval (function () {
time--;
if (time <0) {
time_text.parentNode.replaceChild (linkDL ,text_time);
clearInterval (id);
notif.style.display = "none";
linkDL.style.display = "inline";
linkAL.style.display = "inline";
} else {
text_waktu.innerHTML = "<h3 class = 'text-danger'> The link will appear in" + time.toString () + "Second </h3>";
btn.style.display = "none";
}
}, 2000);
}

cookieOptions = {
msg: "This site uses cookies to help deliver services. By using this site, you agree to the use of cookies.",
link: "https://www.blogger.com/go/blogspot-cookies",
close: "Got it!",
learn: "Learn More"};
//]]>
</script>

3. Copy the following code and paste it into Notepad, replace the url “http://website-anda.com/safelink.html” with the link page that you created earlier.

var Base64 = {
_keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 + / =",
encode: function (input) {
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;
input = Base64._utf8_encode (input);
while (i <input.length) {
chr1 = input.charCodeAt (i ++);
chr2 = input.charCodeAt (i ++);
chr3 = input.charCodeAt (i ++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN (chr2)) {
enc3 = enc4 = 64;
} else if (isNaN (chr3)) {
enc4 = 64;
}
output = output + this._keyStr.charAt (enc1) + this._keyStr.charAt (enc2) + this._keyStr.charAt (enc3) + this._keyStr.charAt (enc4);
}
return output;
},
decode: function (input) {
var output = "";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
input = input.replace (/ [^ A-Za-z0-9 + / =] / g, "");
while (i <input.length) {
enc1 = this._keyStr.indexOf (input.charAt (i ++));
enc2 = this._keyStr.indexOf (input.charAt (i ++));
enc3 = this._keyStr.indexOf (input.charAt (i ++));
enc4 = this._keyStr.indexOf (input.charAt (i ++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode (chr1);
if (enc3! = 64) {
output = output + String.fromCharCode (chr2);
}
if (enc4! = 64) {
output = output + String.fromCharCode (chr3);
}
}
output = Base64._utf8_decode (output);
return output;
},
_utf8_encode: function (string) {
string = string.replace (/ r n / g, " n");
var utftext = "";
for (var n = 0; n <string.length; n ++) {
var c = string.charCodeAt (n);
if (c <128) {
utftext + = String.fromCharCode (c);
} else if ((c> 127) && (c <2048)) {
utftext + = String.fromCharCode ((c >> 6) | 192);
utftext + = String.fromCharCode ((c & 63) | 128);
} else {
utftext + = String.fromCharCode ((c >> 12) | 224);
utftext + = String.fromCharCode (((c >> 6) & 63) | 128);
utftext + = String.fromCharCode ((c & 63) | 128);
}
}
return utftext;
},
_utf8_decode: function (utftext) {
var string = "";
var i = 0;
var c = c1 = c2 = 0;
while (i <utftext.length) {
c = utftext.charCodeAt (i);
if (c <128) {
string + = String.fromCharCode (c);
i ++;
} else if ((c> 191) && (c <224)) {
c2 = utftext.charCodeAt (i + 1);
string + = String.fromCharCode (((c & 31) << 6) | (c2 & 63));
i + = 2;
} else {
c2 = utftext.charCodeAt (i + 1);
c3 = utftext.charCodeAt (i + 2);
string + = String.fromCharCode (((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i + = 3;
}
}
return string;
}
}
var encode = document.getElementById ('encode'),
decode = document.getElementById ('decode'),
output = document.getElementById ('output'),
input = document.getElementById ('input');
var User_ID = "";
var protected_links = "";
var a_to_va = 0;
var a_to_vb = 0;
var a_to_vc = "";
function auto_safelink () {
auto_safeconvert ();
}
function auto_safeconvert () {
var a_to_vd = window.location.hostname;
if (protected_links! = "" &&! protected_links.match (a_to_vd)) {
protected_links + = "," + a_to_vd;
} else if (protected_links == "") {
protected_links = a_to_vd;
}
var a_to_ve = "";
var a_to_vf = new Array ();
var a_to_vg = 0;
a_to_ve = document.getElementsByTagName ("a");
a_to_va = a_to_ve.length;
a_to_vf = a_to_fa ();
a_to_vg = a_to_vf.length;
var a_to_vh = false;
var j = 0;
var a_to_vi = "";
for (var i = 0; i <a_to_va; i ++) {
a_to_vh = false;
j = 0;
while (a_to_vh == false && j <a_to_vg) {
a_to_vi = a_to_ve [i] .href;
if (a_to_vi.match (a_to_vf [j]) ||! a_to_vi ||! a_to_vi.match ("http")) {
a_to_vh = true;
}
j ++;
}
if (a_to_vh == false) {
var encryptedUrl = Base64.encode (a_to_vi);
a_to_ve [i] .href = "http://your-website.com/safelink.html?url=" + encryptedUrl;
a_to_ve [i] .rel = "nofollow";
a_to_vb ++;
a_to_vc + = i + ":::" + a_to_ve [i] .href + " n";
}
}
var a_to_vj = document.getElementById ("anonyminized");
var a_to_vk = document.getElementById ("found_links");
if (a_to_vj) {
a_to_vj.innerHTML + = a_to_vb;
}
if (a_to_vk) {
a_to_vk.innerHTML + = a_to_va;
}
}
function a_to_fa () {
var a_to_vf = new Array ();
protected_links = protected_links.replace ("", "");
a_to_vf = protected_links.split (",");
return a_to_vf;
}

4. Save the Notepad by converting it to a JavaScript file, how to: Rename (eg filesafelink.txt) the Notepad file above that you edited and saved with the .js extension (eg filesafelink.js)

5. After successfully creating a safelink JavaScript using Notepad, upload the JavaScript file on Github. Copy Paste the JavaScript Github link and Get the code via Rawgit (Important). You can also use YourJavaScript and so on.

6. Copy the code below and place it in the HTML Template [Location:  Wp-Admin > Appearance > Editor > Theme Footer (footer.php) Or  Access Edit Template through CPanel] above the code </body> :

  • JavaScript Link: Edit replace url " URL.JS" with the JavaScript link  that you uploaded earlier.
  • Protected Link: Edit and replace your blogkamu.com with the url of your blog, and add the url address that you don’t want to convert to safelink by adding (,) to each link. “Save” Template.

<script src = 'URL.JS' type = 'text / javascript'> </script>
<script type = 'text / javascript'>
protected_links = "your blogkamu.com, facebook.com, twitter.com, youtube.com, goo.gl";
auto_safelink ();
</script>

7. Copy and paste the code below into the safelink page that you created earlier. Information :

  • Ad Placement: Replace Ads 1 and  Ads 2 with the ad you want to display.
  • Page Url Code: replace url "http://website-anda.com/safelink.html" with the link for your safelink page.
  • JavaScript Link: Edit replace url "URL.JS" with the JavaScript link  that you uploaded earlier. Save Page

<center>
Ads 1
<script type = "text / javascript">
// <! [CDATA [
function changeLink () {
var e = Base64.decode (res);
window.open (e, "_self")
}
var currentURL = location.href,
str = currentURL,
res = str.replace ("http://your-website.com/safelink.html?url=", "");
document.write ('<button target = "_ self" class = "btn btn-success" style = "display: block; font-size: small" id = "download" onclick = "changeLink ()"> Continue </ button > ');
onload: generate ();
//]]>
</script>
<script src = "URL.JS" type = "text / javascript"> </script>
Ads 2
</center>

Now the Self Hosting WordPress Blog or if you use the above method for blogspot you can successfully Convert Links automatically on your main blog page.

Conclusion

The advantage of using this method is that you don’t have to bother creating a new blog because Safelink is in the main blog, besides that, Safelink traffic will also be one with the main blog traffic which will make your blog visitors look high.

If you are having problems not appearing adsense ads or your other ads on your safelink page, you can leave a comment below.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top