Skip to content

Instantly share code, notes, and snippets.

Coen Jacobs coenjacobs

Block or report user

Report or block coenjacobs

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
View example-coupled-meta-class.php
<?php
class MetaChecker {
public function checkMeta( WP_Post $post ) {
$value = get_post_meta($post->ID, 'key_of_value_store', true);
// @TODO: Do magic with $value
}
}
View setup-method-class.php
<?php
class Object {
public function setup() {
add_action('init', array($this, 'init') );
}
}
View AbstractType.php
<?php
namespace CoenJacobs\StefExample\PostTypes;
abstract class AbstractType {
public function setup() {
// possibly some setup logic here?
}
public function register() {
View keybase.md

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 / wordpress-you-make-me-mad.php
Created Jan 29, 2015
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…
View wordpress-you-make-me-mad.php
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 / up.sh
Created Jul 22, 2014
I use this script to run commands over SSH in a new Vagrant machine to setup my own dotfiles.
View up.sh
#!/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 / wc-shop-loop-columns.php
Created Feb 15, 2014
Change the number of columns in which products will be shown on product archives
View wc-shop-loop-columns.php
<?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 ) {
@coenjacobs
coenjacobs / wc-custom-product-order.php
Created Jun 18, 2013
Adds a custom way of ordering products, in this example it's 'random' product ordering. This can also be set to be used as default via the Catalog tab in WooCommerce settings.
View wc-custom-product-order.php
<?php
add_filter( 'woocommerce_get_catalog_ordering_args', 'custom_woocommerce_get_catalog_ordering_args' );
function custom_woocommerce_get_catalog_ordering_args( $args ) {
$orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
if ( 'random_list' == $orderby_value ) {
$args['orderby'] = 'rand';
$args['order'] = '';
@coenjacobs
coenjacobs / wc-disable-shipping-for-classes.php
Created Apr 14, 2013
Disables specific shipping methods if there are products with one or more specified shipping classes in the cart.
View wc-disable-shipping-for-classes.php
<?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
*/
@coenjacobs
coenjacobs / wc-remove-dutch-provinces.php
Created Jan 29, 2013
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.
View wc-remove-dutch-provinces.php
<?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' );
You can’t perform that action at this time.