Skip to content

Instantly share code, notes, and snippets.

View jdevalk's full-sized avatar
😀

Joost de Valk jdevalk

😀
View GitHub Profile
@jdevalk
jdevalk / archive-speaking_event.php
Last active December 12, 2021 20:13
Genesis helper code for schema
<?php
add_filter( 'genesis_attr_content', 'yoast_schema_empty', 20 );
add_filter( 'genesis_attr_entry', 'yoast_schema_event', 20 );
add_filter( 'genesis_attr_entry-title', 'yoast_itemprop_name', 20 );
add_filter( 'genesis_attr_entry-content', 'yoast_itemprop_description', 20 );
add_filter( 'genesis_post_title_output', 'yoast_title_link_schema', 20 );
/**
* We'll use the post info output to add more meta data about the event.
@jdevalk
jdevalk / author-itemprop.php
Last active January 17, 2023 09:58
Bits of schema that require non-schema filters right now, for which I've written these functions
<?php
// For pages where you'd rather not have 20 rel=authors and in fact *do* need itemprop=author
// For instance on http://yoast.com/review/
function yoast_author_schema( $output ) {
return str_replace( 'rel="author"', 'itemprop="author"', $output );
}
add_filter( 'genesis_post_author_posts_link_shortcode', 'yoast_author_schema', 20 );
@jdevalk
jdevalk / gist:5623050
Created May 21, 2013 20:39
Redirect script sample NGINX code. Make sure this location line sits above the "location /" code in your NGINX config.
location /redirect/ {
rewrite ^/redirect/(.*)$ /redirect/index.php?id=$1 last;
}
@jdevalk
jdevalk / .htaccess
Last active January 7, 2025 07:26
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';
}