Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Return a custom field stored by the Advanced Custom Fields plugin
*
* @global $post
* @param str $key The key to look for
* @param mixed $id The post ID (int|str, defaults to $post->ID)
* @param mixed $default Value to return if get_field() returns nothing
* @return mixed
* @uses get_field()
<?php
/** Display verbose errors */
define( 'IMPORT_DEBUG', false );
// Load Importer API
require_once ABSPATH . 'wp-admin/includes/import.php';
if ( ! class_exists( 'WP_Importer' ) ) {
$class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
if ( file_exists( $class_wp_importer ) )
<?php
/* Filter to the post_class. */
add_filter( 'post_class', 'remove_class' );
/**
* Remove class from post_class() function.
*/
function remove_class( $classes ) {
$classes = array_diff( $classes, array( 'hentry' ) ); // seperate with commas for more than one class.
return $classes;
/**
* Description:
* removes white space from text. useful for html values that cannot have spaces
* Usage:
* {{some_text | nospace}}
*/
app.filter('nospace', function () {
return function (value) {
return (!value) ? '' : value.replace(/ /g, '');
<div ng-repeat="m in milestone_choices" class="row-fluid">
<label><input type="radio" name="meaningless" value="(( $index ))" ng-model="milestone_data.index" />
&nbsp;<span ng-bind="m.title"></span></label>
</div>
<?php
/*
Plugin Name: Replace Hasher
Plugin URI: http://christopherdavis.me
Description: Replace the `wp_hash_password` function
Author: Christopher Davis
Author URI: http://christopherdavis.me
License: MIT
Copyright (c) 2012 Christopher Davis
<?php
/*
Plugin Name: Rewrite Rule Tutorials
*/
add_action( 'init', 'pmg_rewrite_add_rewrites' );
function pmg_rewrite_add_rewrites()
{
add_rewrite_endpoint( 'json', EP_PERMALINK );
add_rewrite_rule(
/**
* Remove the slug from published post permalinks. Only affect our CPT though.
*/
function wpex_remove_post_type_slug( $post_link, $post, $leavename ) {
if ( ! in_array( $post->post_type, array( 'YOUR_POST_TYPE' ) ) || 'publish' != $post->post_status )
return $post_link;
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
@toddsby
toddsby / functions.php
Last active August 29, 2015 13:56
Exclude pages from wordpress 'at a glance' aka right now widget using wp_count_posts filter
<?php
/**
* Function to retrive page id by slug
* @param string - page slug name
* @return int - page id
*/
function toddsby_get_page_by_slug($page_slug) {
$page = get_page_by_path($page_slug);
if ($page) {
return $page->ID;
// Modifies $httpProvider for correct server communication (POST variable format)
angular.module('http-post-fix', [], function($httpProvider) {
// This code is taken from http://victorblog.com/2012/12/20/make-angularjs-http-service-behave-like-jquery-ajax/
// Use x-www-form-urlencoded Content-Type
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
// Override $http service's default transformRequest
$httpProvider.defaults.transformRequest = [function(data) {
/**