Skip to content

Instantly share code, notes, and snippets.

View c3mdigital's full-sized avatar

Chris Olbekson c3mdigital

  • WebDev Studios
  • Houston, TX
View GitHub Profile
@c3mdigital
c3mdigital / WordPress.xml
Created November 18, 2012 08:40
WordPress coding style for PhpStorm
<?xml version="1.0" encoding="UTF-8"?>
<code_scheme name="WordPress">
<option name="USE_SAME_INDENTS" value="true" />
<option name="IGNORE_SAME_INDENTS_FOR_LANGUAGES" value="true" />
<option name="OTHER_INDENT_OPTIONS">
<value>
<option name="INDENT_SIZE" value="4" />
<option name="CONTINUATION_INDENT_SIZE" value="8" />
<option name="TAB_SIZE" value="4" />
<option name="USE_TAB_CHARACTER" value="true" />
@c3mdigital
c3mdigital / cacheable-ajax.php
Last active February 19, 2023 13:35
Example of how to cache fronted ajax requests in WordPress. This will allow you to use ajax and page caching like varnish or redis. Where ajax requests would normally not be cached using the built in wp_ajax_action method.
<?php
add_filter( 'rewrite_rules_array', 'cache_frontend_ajax_rules' );
/**
* Rewrite rules filter to add rules for front end ajax calls
*
* @param array $rewrite_rules
*
* @return array
*/
<?php
/**
* WordPress Chosen Taxonomy Metabox
* Author: Helen Hou-Sandi
*
* Use Chosen for a replacement taxonomy metabox in WordPress
* Useful for taxonomies that aren't changed much on the fly and are
* non-hierarchical in nature, as Chosen is for flat selection only.
* You can always use the taxonomy admin screen to add/edit taxonomy terms.
* Categories need slightly different treatment from the rest in order to
@c3mdigital
c3mdigital / class-simple-local-avatars.php
Created June 24, 2012 04:53
Upload custom avatars for users to override gravatar for comments and author_meta
<?php
/*
Plugin Name: Custom WordPress Avatars
Plugin URI: http://c3mdigital.com
Description: Adds a custom avatar uploader in the user profile to replace gravatars with a custom avatar
Version: 1.0
Author: Chris Olbekson
Author URI: http://c3mdigital.com/
License: GPL v2
*/
@c3mdigital
c3mdigital / plugin.php
Last active October 24, 2021 02:10 — forked from joncave/plugin.php
<?php
/* Plugin Name: Damn Vulnerable WordPress Plugin
* Description: Intentionally vulnerable plugin for plugin author education
* Version: 0.1
* Plugin URI: http://make.wordpress.org/plugins/2013/04/09/intentionally-vulnerable-plugin/
* Author: Jon Cave
* Author URI: http://joncave.co.uk
* License: GPLv2+
*
* DO NOT RUN THIS PLUGIN ON AN INTERNET ACCESSIBLE SITE
@c3mdigital
c3mdigital / class-microcache-purge.php
Created November 16, 2012 05:39
WordPress Nginx Multisite Configuration with Nginx Microcahing
/**
* Micro Cache Purge PHP Class
* Sends a request header to nginx to purge the microcache when post are created or updated
* Include this file at plugins_loaded or in theme functions.php
*/
new Micro_Cache_Purge();
class Micro_Cache_Purge {
@c3mdigital
c3mdigital / multiple-post-query.php
Created May 11, 2012 22:12
Custom $wp_query loop to show 3 posts from 3 different post types using only 1 query
<?php
$args = array(
'post_type' => array( 'type1', 'type2', 'type3' ),
'posts_per_page' => -1
);
$myquery = new WP_Query( $args );
$type1 = 0; $type2 = 0; $type3 = 0; $count = 0;
while ( $myquery->have_posts() ) : $myquery->the_post();
@c3mdigital
c3mdigital / gist:2032898
Created March 14, 2012 00:16 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@c3mdigital
c3mdigital / provision.sh
Created May 1, 2014 20:59
Vagrant Provisioning Script
#!/bin/bash
#
# provision.sh
#
# This file is specified in Vagrantfile and is loaded by Vagrant as the primary
# provisioning script whenever the commands `vagrant up`, `vagrant provision`,
# or `vagrant reload` are used. It provides all of the default packages and
# configurations included with Varying Vagrant Vagrants.
# By storing the date now, we can calculate the duration of provisioning at the
@c3mdigital
c3mdigital / git-post-push.md
Last active May 16, 2016 19:16
Git pseudo post-push hook for updating supermodel when changes are made and pushed to submodule

Git post push hook for updating supermodule when submodule is updated

  • Create file named git-push-wh with the following content and add it to your path
#!/bin/sh

GIT_DIR_="$(git rev-parse --git-dir)"

BRANCH="$(git rev-parse --symbolic --abbrev-ref $(git symbolic-ref HEAD))"