Skip to content

Instantly share code, notes, and snippets.

@coenjacobs
coenjacobs / up.sh
Created July 22, 2014 07:39
I use this script to run commands over SSH in a new Vagrant machine to setup my own dotfiles.
#!/bin/bash
vagrant up
vagrant ssh << EOF
# If directory doesn't exist, clone the repository in ~/.dotfiles
if [ ! -d ~/.dotfiles ];
then
git clone --recursive https://github.com/coenjacobs/dotfiles.git ~/.dotfiles
fi
@coenjacobs
coenjacobs / wordpress-you-make-me-mad.php
Created January 29, 2015 09:37
There are use cases where I would agree with not allowing requests to a local host and yes there is a filter... but this took SO LONG to find. Maybe the error message should inform you of when this happens, because now it just says "A valid URL was not provided". Code in WordPress core: https://github.com/WordPress/WordPress/blob/994b57a1902592d…
if ( $ip ) {
$parts = array_map( 'intval', explode( '.', $ip ) );
if ( 127 === $parts[0] || 10 === $parts[0]
|| ( 172 === $parts[0] && 16 <= $parts[1] && 31 >= $parts[1] )
|| ( 192 === $parts[0] && 168 === $parts[1] )
) {
// If host appears local, reject unless specifically allowed.
/**
* Check if HTTP request is external or not.
*
@coenjacobs
coenjacobs / gist:1389756
Created November 23, 2011 20:09 — forked from remkus/gist:1235165
Example of WordPress coding standards
<?php
add_filter( 'body_class' , 'ft_add_guest_body_class' );
/**
* Adds a body class for guests.
*
* @author Remkus de Vries
* @link http://remkusdevries.com/when-sharing-wordpress-related-code-snippets-i-can-haz-standards-please/
* @tested WordPress 3.2.1
* @param array $classes Existing body classes
@coenjacobs
coenjacobs / custom-login.js
Created January 25, 2012 10:21
Adding a link to wp-login.php via jQuery
jQuery( document ).ready(function( $ ) {
var href = $("#nav a").attr("href");
var html = '<a href="'+ href +'">First login?</a> - ';
$( "#nav" ).prepend( html );
} );
@coenjacobs
coenjacobs / archive-recept.php
Created March 25, 2012 21:01
Demonstration plugin that registers a post type for 'recipes'. This code is not fully tested, is not 100% written according to the WordPress Coding Standards and could use function prefixing to minimize the risk of having duplicate function names.
<?php get_header(); ?>
<div id="container">
<div id="content" role="main">
<h1 class="page-title">Recepten</h1>
<?php get_template_part( 'loop', 'recept' ); ?>
</div>
@coenjacobs
coenjacobs / gist:2571441
Created May 1, 2012 21:12 — forked from boonebgorges/gist:2571318
Update Woo Framework for all WooThemes on an installation
<?php
/**
* Updates Woo Framework in all WooThemes on a WP installation
*
* To use:
*
* - Get the latest copy of the framework
* - Unzip to /wp-content/framework/
* - Visit wp-admin?cac_update_woo=1 as super admin
@coenjacobs
coenjacobs / wc-remove-dutch-provinces.php
Created January 29, 2013 13:33
Removes the Dutch provinces from WooCommerce country dropdown boxes as they are not required for Dutch shops. Will become superfluous once WooCommerce 2.0 is released. Important: Make sure you select 'Netherlands' as country again in WooCommerce settings.
<?php
/*
Plugin Name: WC Remove Dutch Provinces
Description: Removes the Dutch provinces from the WooCommerce country dropdown boxes, no need to show these. Will become superfluous once WooCommerce 2.0 is released. Important: Make sure you select 'Netherlands' as country again in WooCommerce settings.
Author: Coen Jacobs
Author URI: http://coenjacobs.me/
*/
add_filter( 'woocommerce_states', 'cj_woocommerce_states' );
@coenjacobs
coenjacobs / wc-disable-shipping-for-classes.php
Created April 14, 2013 22:19
Disables specific shipping methods if there are products with one or more specified shipping classes in the cart.
<?php
/*
Plugin Name: WC Disable Shipping for Classes
Description: Disables specific shipping methods if there are products with one or more specified shipping classes in the cart.
Author: Coen Jacobs
Author URI: http://coenjacobs.me
Version: 1.0
*/

Keybase proof

I hereby claim:

  • I am CoenJacobs on github.
  • I am coenjacobs (https://keybase.io/coenjacobs) on keybase.
  • I have a public key whose fingerprint is 4925 71BD 1469 C165 B383 A62A 5D7F A24B B215 0324

To claim this, I am signing this object:

@coenjacobs
coenjacobs / wc-shop-loop-columns.php
Created February 15, 2014 22:39
Change the number of columns in which products will be shown on product archives
<?php
add_filter( 'loop_shop_columns', 'wc_loop_shop_columns', 1, 10 );
/*
* Return a new number of maximum columns for shop archives
* @param int Original value
* @return int New number of columns
*/
function wc_loop_shop_columns( $number_columns ) {