Skip to content

Instantly share code, notes, and snippets.

View jdevalk's full-sized avatar
😀

Joost de Valk jdevalk

😀
View GitHub Profile
<?php
function trueGoogle404_showlink()
{
$a=get_option('tG404mis');echo '<span style="font-size:8px;">';
if($a===false)
{
@jdevalk
jdevalk / add-to-cart-by-get.php
Created December 3, 2012 12:42
Add to cart by GET request
<?php
/**
* Convenience function to allow linking to a checkout page and adding the product to the cart in one swoop.
*/
function edd_add_to_cart_by_get( ) {
if ( edd_is_checkout() ) {
if ( isset( $_GET['edd_add_to_cart'] ) ) {
edd_add_to_cart( intval( $_GET['edd_add_to_cart'] ) );
}
@jdevalk
jdevalk / jwplayer-video-thumb.php
Created December 7, 2012 08:35
Include thumbnail from custom field for JW Player video's
<?php
// You can add the code below to your theme's functions.php
/**
* Filter the vid array to include thumbnail.
*
* @param array $vid The video array as determined by the indexation process
*
* @return array
<?php
function yst_shareasale_tracking( $content ) {
global $edd_options;
if ( is_page( $edd_options['success_page'] ) ) {
if ( isset( $_GET['cm'] ) ) {
$order_id = intval( $_GET['cm'] );
} else if ( function_exists( 'edd_get_purchase_id_by_key' ) ) {
$pd = edd_get_purchase_session();
<?php
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
require_once plugin_dir_path( __FILE__ ) . 'admin/ajax.php';
} else if ( defined('DOING_CRON') && DOING_CRON ) {
$options = get_option( 'Yoast_Google_Analytics' );
if ( isset( $options['yoast_tracking'] ) && $options['yoast_tracking'] )
@jdevalk
jdevalk / archive-wpseo_locations.php
Last active July 14, 2019 23:32
A cool example of what your locations post type archive page could look like
<?php
/**
* Template for displaying a map on the locations post-type archive page.
*
* @package Twenty_Twelve
* @subpackage Local SEO for WordPress Archive page template
* @author Joost de Valk
*/
get_header();
@jdevalk
jdevalk / gist:5317986
Last active December 15, 2015 20:19
.htaccess hack to make WordPress SEO core files and locations.kml and geo_sitemap.xml work on sites that flush rewrite rules too often.
# WordPress SEO - XML Sitemap Rewrite Fix
RewriteEngine On
RewriteBase /
RewriteRule ^sitemap_index.xml$ /index.php?sitemap=1 [L]
RewriteRule ^locations.kml$ /index.php?sitemap=wpseo_local_kml [L]
RewriteRule ^geo_sitemap.xml$ /index.php?sitemap=geo [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
@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
@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