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 / nginx.conf
Created March 11, 2012 00:28
Nginx conf file
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
# multi_accept on;
}
http {
@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 / 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 / nginx.conf
Created May 22, 2012 00:24
Updated Ningx.conf and WordPress multi site block
## Start nginx.conf
user www-data;
worker_processes 8;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
@c3mdigital
c3mdigital / sidebar_select.php
Created June 3, 2012 00:31
Sidebar Select Meta Box for cmb_meta_boxes
<?php
/**
* Adds a new sidebar_select field type to CMB Metaboxes
*
* Builds the select box from all registered sidebars.
* Use in themes to create per page or post layout options without having to create new templates
*
* @see https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress.git
*
*/
@c3mdigital
c3mdigital / inspect_hooks.php
Created June 22, 2012 22:52 — forked from stephenh1988/inspect_hooks.php
Inspect hooks in WP by adding &debug=true&hook=my_hook_name to the request URl
<?php
/**
* Plugin Name: Hook Debug Output
* Plugin URI: http://unserkaiser.com
* Description: Debug Hooked filter callback functions with adding <code>?debug=secret&hook=your_hook_name</code> to the URl
* Version: 0.1
* Author: Stephen Harris, Franz Josef Kaiser
* Author URI: http://unserkaiser.com
*/
// Prevent loading this file directly - Busted!
@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 / get_perm_byname.php
Created July 26, 2012 08:41
Get WordPress permalink from post, page or custom post type name
<?php
/**
* Gets the permalink from the post slug
* @param string $name the post, page or custom post type slug
* @param string $p_type the post type
*
* @return string The permalink YAHHH!!!
*/
function get_perm_byname( $name, $p_type = 'page' ) {
@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 / front-end-uploads.php
Created November 16, 2012 17:14
Two file upload handler functions
/**
* File upload ajax handler function to save the file and send image or file html back to the browser
* These functions are part of a class
*/
function ajax_upload_file() {
check_ajax_referer( 'ugc_user_upload', 'nonce' );
$file_data = array(
'name' => $_FILES['ugc_attachment_file']['name'],
'type' => $_FILES['ugc_attachment_file']['type'],
'tmp_name' => $_FILES['ugc_attachment_file']['tmp_name'],