Skip to content

Instantly share code, notes, and snippets.

View Xyborg's full-sized avatar
🐍
Python for SEO

Martín Aberastegue Xyborg

🐍
Python for SEO
View GitHub Profile
@Xyborg
Xyborg / theme-funciont-url-canonical-seobyyoast.php
Last active August 29, 2015 14:14
SEO by Yoast: Exclude URLs from canonical
/* Add this function to the functions.php in your theme folder */
/* to exclude certain posts from url canonicalization of SEO by Yoast plugin */
function wpseo_canonical_exclude( $canonical ) {
global $post;
if ( get_post_type( get_the_ID() ) == "name_your_post_type") {
//if ( $post->ID == 7777) {
$canonical = false;
}
return $canonical;
}
@Xyborg
Xyborg / f-ck-semalt.htaccess
Created January 29, 2015 04:59
F*ck Semalt referral SPAM
# Block visits from semalt.com domains and subdomains by @Xyborg
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://([^.]+\.)*semalt\.com [NC]
RewriteRule (.*) http://www.semalt.com/?utm_source=Google&utm_medium=organic&utm_term=go_away [R=301,L]
### Keybase proof
I hereby claim:
* I am Xyborg on github.
* I am xyborg (https://keybase.io/xyborg) on keybase.
* I have a public key whose fingerprint is D184 49B6 F64A D3A3 EB26 8DEE EDE5 E5F2 3481 0314
To claim this, I am signing this object:
Put the following lines before the default WP code:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
It should look like this:
RewriteEngine On
RewriteCond %{HTTPS} !=on
@Xyborg
Xyborg / open-wp-links-taget_blank.php
Last active November 16, 2018 12:55
Open WordPress content links on a new tab (target="_blank")
@Xyborg
Xyborg / Disable PHP Execution in Certain Directories
Created May 8, 2019 12:23
Disable PHP Execution in Certain Directories
<Files "^(*.php|*.phps)">
order deny,allow
deny from all
</Files>
@Xyborg
Xyborg / Facebook Pixel Code ECIPSA (header)
Created May 20, 2019 18:36
Facebook Pixel Code ECIPSA (header)
<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
@Xyborg
Xyborg / Facebook Pixel Code ECIPSA Conversion (body)
Created May 20, 2019 18:58
Facebook Pixel Code ECIPSA Conversion (body)
<script>
fbq('track', 'CompleteRegistration');
</script>
#!/usr/bin/env python
import sys, os, time
import tweepy
keys = dict(
consumer_key='_YOUR_CONSUMER_KEY',
consumer_secret='_YOUR_SECRET_KEY',
access_token='_YOUR_ACCESS_TOKEN',
access_token_secret='_YOUR_ACCESS_TOKEN_SECRET'
)
#!/usr/bin/python
"""Uso de Google Search Analytics API (part of Search Console API).
Mas info en: https://developers.google.com/webmaster-tools/
To use:
1) Install the Google Python client library, as shown at https://developers.google.com/webmaster-tools/v3/libraries.
2) Sign up for a new project in the Google APIs console at https://code.google.com/apis/console.
3) Register the project to use OAuth2.0 for installed applications.
4) Copy your client ID, client secret, and redirect URL into the client_secrets.json file included in this package.