Skip to content

Instantly share code, notes, and snippets.

Joost de Valk jdevalk

Block or report user

Report or block jdevalk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jdevalk
jdevalk / two-products-best.json
Last active May 7, 2019
Two JSON blobs, one with the main product, a second one that can be output later on the page that clearly relates itself to the first one as a related product.
View two-products-best.json
<script type="application/ld+json">{
"@context": "https://schema.org",
"@graph": [
{
"@type": "Organization",
"@id": "https://example.com/#organization",
"name": "Yoast",
"url": "https://example.com/",
"sameAs": [
"https://www.facebook.com/yoast",
@jdevalk
jdevalk / svgs.md
Last active Jul 13, 2018
What to do with SVG's
View svgs.md

Regex search:

  • style=(["|'])fill:#([a-zA-Z0-9]{3,});\1 replace with fill="#$2"
  • (class|id)=(["|'])([a-zA-Z_0-9-^-]+)\2 replace with blank

In a nuttshell:

  • Remove <title> and <decoration> if the image is “just decoration”.
  • Add role="img" aria-hidden="true" focusable="false" to the svg. Exclude aria-hidden="true" if its an infographic.
  • If its important to understand the “svg” in order to understand what the page is about, use aria-labelledby="title desc" on the SVG and use <title> and <desc> element in the SVG.
View remove-redirect.md

Why we removed redirects from the advanced tab of Yoast SEO

Yes, we have prevented you from adding new 301 redirects in the advanced tab of the Yoast SEO meta box. And we have a couple of very good reasons for that.

As it was, it was virtually impossible to keep track of what post is redirected where. You’d have to open each post or visit each URL to find out. This was causing quite a mess over time.

Our Yoast SEO Premium customers, who have access to a far better redirects module, often ran into posts that were redirected while no redirect was set in the redirects module. Having to manage redirects in a couple of different locations really is undoable.

Checking for the set 301 redirect also requires us to do an extra query on every pageload. Which means we had to slow your website down a bit, just to check if there was a redirect set. Since speed is gaining importance as a ranking factor, we are constantly looking how we can further optimize our plu

@jdevalk
jdevalk / dev-environment.php
Created Jul 23, 2015
Throw this in your dev environments mu-plugins folder and add it to your .gitignore file :)
View dev-environment.php
<?php
/**
* Disables plugins on your dev environment
*
* @param $plugins
*
* @return mixed
*/
function yst_dev_env_disable_plugins( $plugins ) {
View explanation.md

If you use HelpScout's Docs product, you want to be able to search that Docs site when you're creating links in your WordPress install. Using the Better Internal Link Search plugin and this piece of code, you can. It'll look like this:

Docs search

Add the code below to one of your must use plugins, or even insert it as a single plugin on its own:

@jdevalk
jdevalk / logging-helper.php
Last active May 7, 2019
This little hack enables fatal error logging for your site, without creating an error log that is insanely big.
View logging-helper.php
<?php
/**
* This changes logging to only log fatal errors. This file should go in your mu-plugins directory.
*/
// Set the error logging to only log fatal errors
error_reporting( E_ERROR );
// Optional: change the location of your error log, it might be wise to put it outside your WP content dir.
// If you don't change it, the default place for this log is debug.log in your WP_CONTENT_DIR.
@jdevalk
jdevalk / gist:ca4fefd3a3122e86ce49
Created Apr 22, 2015
This gist allows you to prevent the redirect to the about page, the intro tour from showing up and the tracking popup from ever showing.
View gist:ca4fefd3a3122e86ce49
<?php
/**
* Filter the contents of the WP SEO option
*
* @param array $option The WP SEO main option values
*
* @return array
*/
function filter_yst_wpseo_option( $option ) {
@jdevalk
jdevalk / gist:c06834fb4e8c9953a563
Last active Oct 9, 2018
Snippet to replace image URIs with CDN image URIs in the XML sitemaps generated by WordPress SEO by Yoast. Obviously replace yoast.com with whatever is your site's domain.
View gist:c06834fb4e8c9953a563
<?php
/**
* Replace image URIs with CDN image URIs
*
* @param string $uri
*
* @return string
*/
function yst_cdn_filter( $uri ) {
@jdevalk
jdevalk / yoast-glotpress-seo.php
Last active Aug 9, 2016
Small SEO plugin for GlotPress
View yoast-glotpress-seo.php
<?php
class Yoast_GlotPress_SEO {
function __construct() {
add_filter( 'gp_title', array( $this, 'modify_title' ) );
add_action( 'gp_head', array( $this, 'meta_desc' ), 9 );
add_filter( 'gp_redirect_status', array( $this, 'modify_redirect_status' ), 10, 2 );
}
@jdevalk
jdevalk / gist:0b2ddd13d27cf869a976
Created Oct 1, 2014
Change WP SEO JSON+LD search URL from ?s= to /search/
View gist:0b2ddd13d27cf869a976
<?php
/**
* Changes the search slug to /search/ for the JSON+LD output
*/
function yst_change_json_ld_search_url() {
return trailingslashit( home_url() ) . 'search/{search_term}';
}
add_filter( 'wpseo_json_ld_search_url', 'yst_change_json_ld_search_url' );
You can’t perform that action at this time.