Skip to content

Instantly share code, notes, and snippets.

<?php
$result = wp_remote_get('yourredirectingdomain.com');
$history = $result['http_response']->get_response_object()->history;
foreach( $history as $part ) {
echo $part->headers->getValues('location');
}
<?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
}
}
<?php
class Object {
public function setup() {
add_action('init', array($this, 'init') );
}
}
<?php
namespace CoenJacobs\StefExample\PostTypes;
abstract class AbstractType {
public function setup() {
// possibly some setup logic here?
}
public function register() {

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 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 / 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 / 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 ) {
@coenjacobs
coenjacobs / wc-custom-product-order.php
Created June 18, 2013 09:32
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.
<?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 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
*/