Skip to content

Instantly share code, notes, and snippets.

View jdevalk's full-sized avatar
😀

Joost de Valk jdevalk

😀
View GitHub Profile
<!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++) {
<?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 June 4, 2014 11:49
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?
<?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 August 29, 2015 14:05
NGINX config for @dannyvankooten's EDD SL API Endpoint code
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 April 22, 2015 07:31
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.
<?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 ) {

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 September 14, 2011 18:55
new rel_canonical function
<?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 October 18, 2011 08:08
New index for Carly
<?php
get_header();
query_posts('posts_per_page=4&cat=-46');
if (have_posts()) :
$first = true;
@jdevalk
jdevalk / wordstream-api-class.php
Created October 23, 2011 19:39
WordStream API interface class for WordPress
<?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 November 8, 2011 11:50
Function to move searches for non-post post-types / taxonomies to their respective archives.
<?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();