Skip to content

Instantly share code, notes, and snippets.

Avatar

Joost de Valk jdevalk

View GitHub Profile
View snippet-test.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<script type="text/javascript">
function showGTitle() {
var gText1 = document.getElementById('gtext1pete').value;
var gBold1 = document.getElementById('gbold1pete').value;
var gWords1 = gBold1.split(' ');
for(var gI1=0; gI1<gWords1.length; gI1++) {
View raw_html_filter.php
<?php
/**
* Make the `vc_raw_html` shortcodes content available to the video seo plugin for indexing.
*
* @param string $content The post content
*
* @return string
*/
function yst_make_raw_html_detectable( $content ) {
@jdevalk
jdevalk / no-widgets-for-xml.php
Created Jun 4, 2014
When loading an XML sitemap, WordPress still does a number of queries for all the widgets, if I did this in WordPress SEO, do you think that'd "kill" things?
View no-widgets-for-xml.php
<?php
if ( isset( $_SERVER['REQUEST_URI'] ) && in_array( substr( $_SERVER['REQUEST_URI'], -4 ), array( '.xml', '.xsl' ) ) ) {
remove_all_actions( 'widgets_init' );
}
@jdevalk
jdevalk / 1 Server block
Last active Aug 29, 2015
NGINX config for @dannyvankooten's EDD SL API Endpoint code
View 1 Server block
if ( $query_string ~ "^edd_action=" ) {
set $edd_api 1;
}
if ( $request_uri ~ "^/edd-sl-api" ) {
set $edd_api 2;
}
if ( $edd_api = 1 ) {
return 307 https://example.com/edd-sl-api$request_uri;
}
@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 ) {
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 / gist:1217431
Created Sep 14, 2011
new rel_canonical function
View gist:1217431
<?php
// this would replace the rel_canonical function in wp-includes/link-template.php
/**
* Output rel=canonical
*
* @package WordPress
* @since 2.9.0
*/
@jdevalk
jdevalk / index.php
Created Oct 18, 2011
New index for Carly
View index.php
<?php
get_header();
query_posts('posts_per_page=4&cat=-46');
if (have_posts()) :
$first = true;
@jdevalk
jdevalk / wordstream-api-class.php
Created Oct 23, 2011
WordStream API interface class for WordPress
View wordstream-api-class.php
<?php
/**
* Class containing all the functionality to get data from the WordStream API
*
* @link http://api.wordstream.com/doc/introduction
*
* @author Joost de Valk <joost@yoast.com>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
@jdevalk
jdevalk / gist:1347575
Created Nov 8, 2011
Function to move searches for non-post post-types / taxonomies to their respective archives.
View gist:1347575
<?php
function yoast_change_template( $template ) {
global $wp_query;
if ( !isset($wp_query->query_vars['taxonomy']) )
return $template;
$taxonomy = get_taxonomy( $wp_query->query_vars['taxonomy'] );
if ( is_search() && count( $taxonomy->object_type ) > 0 && !in_array( 'post', array_values($taxonomy->object_type) ) ) {
set_query_var('post_type', $taxonomy->object_type[0]);
$newtemplate = get_archive_template();