Skip to content

Instantly share code, notes, and snippets.

View colinhowells's full-sized avatar

Colin Howells colinhowells

View GitHub Profile
@clarklab
clarklab / wp_insert_post_front_end_form.php
Created May 25, 2012 00:12
This is a sample front-end form using wp_insert_post(). It's quickly stripped out of my production code from Android and Me, and hasn't been tested alone, so please take it with a grain of salt.
<?
if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['insert_post'] )) { //check that our form was submitted
$title = $_POST['thread_title']; //set our title
if ($_POST['thread_description']=="") { // check if a description was entered
$description = "See thread title..."; // if not, use placeholder
} else {
$description = $_POST['thread_description']; //if so, use it
@willurd
willurd / web-servers.md
Last active December 24, 2025 13:30
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@joakimbeng
joakimbeng / router.html
Last active March 15, 2024 06:18
A really simple Javascript router
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Building a router</title>
<script>
// Put John's template engine code here...
(function () {
// A hash to store our routes:
@nikolov-tmw
nikolov-tmw / functions.php
Created September 4, 2014 22:54
Reusable WP template for PHP and JS
<?php
function load_js_template(){
get_template_part( 'sample-template' );
}
add_action( 'wp_footer', 'load_js_template' );
function render_template( $template_name, $tmpl_data ) {
// "/" should not be present, but let's sanitize just in case
$template_name = str_replace( '/', '_', $template_name );
@fanian
fanian / bootstrap carousel height
Created November 25, 2014 19:29
Normalize Carousel Heights - pass in Bootstrap Carousel items
@mathetos
mathetos / custom-wordpress-feed
Created December 9, 2014 03:30
Custom WordPress RSS Feed with Featured Image Enclosure
<?php
/**
* Custom WordImpress RSS2 Feed
* Integrates Featured Image as "Enclosure"
* See http://www.rssboard.org/rss-2-0-1#ltenclosuregtSubelementOfLtitemgt
* for RSS 2.0 specs
* @package WordPress
*/
header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
@timersys
timersys / mamp-curl
Created February 9, 2015 23:01
Update MAMP / MAMP pro Curl
download curl from http://ftp.sunet.se/pub/www/utilities/curl/curl-7.40.0.tar.bz2
Configure it with ./configure --prefix=/Applications/MAMP/Library/
make && make install
@logoscreative
logoscreative / plugin.php
Last active February 1, 2023 12:14
Friendlier, Safer WordPress Admin Areas
<?php
/**
* "Friendlier, Safer WordPress Admin Areas"
* Presented by Cliff Seal at WordCamp Atlanta 2015 and Asheville 2016
* Slides: http://www.slideshare.net/cliffseal/wp-admin
*
* Plugin Name: A Better Admin Experience
* Plugin URI: http://evermoresites.com
* Description: Cleans up and sanitizes the WordPress admin area
* Version: 1.0
@developit
developit / Mithril.js for React People.md
Last active August 13, 2018 09:52
Mithril.js for React People

Mithril.js for React People

This is a really basic "todo list" demo built with Mithril.

It's largely an ES6/ES2015 port of the Mithril's Getting Started guide, with a bit of sugar and opinion thrown in to make it look and feel a lot like React.

In this case we're using Babel's JSX transform to convert inline XML into hyperscript (just nested calls to Mithral's m() function).

A Pen by Jason Miller on CodePen.

@vielhuber
vielhuber / index.php
Last active July 17, 2023 14:20
load wpdb outside in external php file #php #wordpress
<?php
// minimal version
define( 'SHORTINIT', true );
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );
// medium version (With lots of overhead)
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );
// full version (including functions and 200 header)
define( 'SHORTINIT', true );