Skip to content

Instantly share code, notes, and snippets.

View jdevalk's full-sized avatar
😀

Joost de Valk jdevalk

😀
View GitHub Profile
@jdevalk
jdevalk / .htaccess
Last active November 28, 2023 20:28
These three files together form an affiliate link redirect script.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteRule (.*) ./index.php?id=$1 [L]
</IfModule>
<?php
/**
* Example function description
*
* @since {Next WordPress SEO Version}
*
* @param {array, string, int, objext} {$variable_name} {Short description}
* @param {array, string, int, objext} {$variable_name} {Short description}
*
@jdevalk
jdevalk / gist:5528160
Last active December 17, 2015 01:28
Gravatar comment verification...
<?php
/**
* Check whether a comment author is using a valid gravatar email address, if he/she is, approve the comment.
*
* @param bool $approved Whether or not the comment is approved alreadt.
* @param array $comment The entire comment object.
*
* @return bool $approved
*/
@jdevalk
jdevalk / gist:5465432
Created April 26, 2013 06:55
Add excerpt to the content to be scanned by the WP SEO Video plugin
<?php
function fix_content_input( $content, $vid ) {
$post = get_post( $vid['post_id'] );
if ( !empty( $post->post_excerpt ) )
$content = "\n" . $post->post_excerpt . "\n" . $content;
return $content;
}
add_filter( 'wpseo_video_index_content', 'fix_content_input', 10, 2 );
@jdevalk
jdevalk / post_excerpt.php
Last active February 9, 2019 15:50
If you have the YouTube code in your post excerpt, this will fix it.
<?php
function fix_content_input( $content, $vid ) {
$post = get_post( $vid['post_id'] );
if ( !empty( $post->post_excerpt ) ) {
$content = "\n" . 'http://youtube.com/v/'. $post->post_excerpt . "\n" . $content;
}
return $content;
}
add_filter( 'wpseo_video_index_content', 'fix_content_input', 10, 2 );
@jdevalk
jdevalk / gist:5411371
Created April 18, 2013 09:12
NGINX rewrites for WordPress SEO XML Sitemaps
# Rewrites for WordPress SEO XML Sitemap
rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
<?php
// If you have a function with a default argument:
function bla ( $echo = true ) {
if ( !$echo )
return 'bla';
else
echo 'bla';
}
@jdevalk
jdevalk / gist:5345872
Created April 9, 2013 13:57
Fix XML sitemaps to work by forcing .htaccess to pick them up. Add this to the .htaccess, above the WordPress rewrites. This version assumes you're using a subfolder install with WordPress installed in /wordpress/, adapt if needed.
# WordPress SEO - XML Sitemap Rewrite Fix
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^sitemap_index.xml$ /wordpress/index.php?sitemap=1 [L]
RewriteRule ^([^/]+?)-sitemap([0-9]+)?.xml$ /wordpress/index.php?sitemap=$1&sitemap_n=$2 [L]
# END WordPress SEO - XML Sitemap Rewrite Fix
@jdevalk
jdevalk / gist:5345863
Last active December 16, 2015 00:09
Fix XML sitemaps to work by forcing .htaccess to pick them up. Add this to the .htaccess, **above** the WordPress rewrites.
# WordPress SEO - XML Sitemap Rewrite Fix
RewriteEngine On
RewriteBase /
RewriteRule ^sitemap_index.xml$ /index.php?sitemap=1 [L]
RewriteRule ^([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 [L]
RewriteRule ^([a-z]+)?-?sitemap.xsl$ /index.php?xsl=$1 [L]
# END WordPress SEO - XML Sitemap Rewrite Fix
# WordPress SEO - XML Sitemap Rewrite Fix - for subfolder install
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^sitemap_index.xml$ /wordpress/index.php?sitemap=1 [L]
RewriteRule ^locations.kml$ /wordpress/index.php?sitemap=wpseo_local_kml [L]
RewriteRule ^geo_sitemap.xml$ /wordpress/index.php?sitemap=wpseo_local [L]
RewriteRule ^([^/]+?)-sitemap([0-9]+)?.xml$ /wordpress/index.php?sitemap=$1&sitemap_n=$2 [L]
# END WordPress SEO - XML Sitemap Rewrite Fix