Skip to content

Instantly share code, notes, and snippets.

Contract Killer 3

Revised date: 07/11/2012

Between us [company name] and you [customer name]

Summary:

We’ll always do our best to fulfil your needs and meet your expectations, but it’s important to have things written down so that we both know what’s what, who should do what and when, and what will happen if something goes wrong. In this contract you won’t find any complicated legal terms or long passages of unreadable text. We’ve no desire to trick you into signing something that you might later regret. What we do want is what’s best for both parties, now and in the future.

@tommcfarlin
tommcfarlin / meta-data-serialization.php
Last active November 4, 2022 00:28
An example function used to demonstrate how meta data is typically saved in a WordPress theme or plugin. The gist is made public so that developers can contribute to the standard security boilerplate functionality in order to simplify, reduce, and improve our serialization functions.
<?php
/**
* An example function used to demonstrate how to use the `user_can_save` function
* that provides boilerplate security checks when saving custom post meta data.
*
* The ultimate goal is provide a simple helper function to be used in themes and
* plugins without the need to use a set of complex conditionals and constants.
*
* Instead, the aim is to have a simplified function that's easy to read and that uses
* WordPress APIs.
@garyc40
garyc40 / ajax-submit.js
Created October 3, 2012 15:35
WordPress AJAX form submission
jQuery('#myForm1').ajaxForm({
data: {
// additional data to be included along with the form fields
},
dataType: 'json',
beforeSubmit: function(formData, jqForm, options) {
// optionally process data before submitting the form via AJAX
},
success : function(responseText, statusText, xhr, $form) {
// code that's executed when the request is processed successfully
@garyc40
garyc40 / ajax-hooks.php
Created October 3, 2012 15:27
Hooking into WordPress AJAX actions
// if both logged in and not logged in users can send this AJAX request,
// add both of these actions, otherwise add only the appropriate one
add_action( 'wp_ajax_nopriv_myajax-submit', 'myajax_submit' );
add_action( 'wp_ajax_myajax-submit', 'myajax_submit' );
function myajax_submit() {
// get the submitted parameters
$postID = $_POST['postID'];
// generate the response
@garyc40
garyc40 / ajax-hooks.php
Created October 3, 2012 15:15
WordPress AJAX hooks
// this hook is fired if the current viewer is not logged in
do_action( 'wp_ajax_nopriv_' . $_REQUEST['action'] );
// if logged in:
do_action( 'wp_ajax_' . $_POST['action'] );
@garyc40
garyc40 / enqueue-localize-js.php
Created October 3, 2012 14:58
Enqueue & localize JS in WordPress
// embed the javascript file that makes the AJAX request
wp_enqueue_script( 'my-ajax-request', plugin_dir_url( __FILE__ ) . 'js/ajax.js', array( 'jquery' ) );
// declare the URL to the file that handles the AJAX request (wp-admin/admin-ajax.php)
wp_localize_script( 'my-ajax-request', 'MyAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
@wpsmith
wpsmith / wp_user_query.php
Created August 14, 2012 21:37
WP_User_Query
<?php
/**
* WordPress WP_User_Query Comprehensive Reference
* Compiled by wpsmith - wpsmith.net
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_User_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.4.1/wp-includes/user.php
*/
$args = array(
@awshout
awshout / foundation3-navbar-menu.php
Last active October 13, 2021 17:07
WordPress Menu & Walker for ZURB's Foundation 3 Nav Bar
<?php
add_theme_support('menus');
/*
http://codex.wordpress.org/Function_Reference/register_nav_menus#Examples
*/
register_nav_menus( array(
'main-menu' => 'Main Menu' // registers the menu in the WordPress admin menu editor
) );
@larswittenberg
larswittenberg / media-queries-debugger
Last active October 7, 2015 04:28
Media Queries Debugging
/* Simple Media Queries Debugging */
/* http://bueltge.de/test/media-query-debugger.php */
@media all {
body::before {font-weight: 900; display: block; text-align: center; position: absolute; padding: .6em; position: fixed; top: 0; left: 0; right: 0; z-index: 2000;}
}
@media all and (-webkit-min-device-pixel-ratio : 1.5),
all and (min-device-pixel-ratio : 1.5) { body::before { content: "iPhone 4 and high pixel ratio devices"; background: rgba(139, 69, 19, 0.8); } }
@media all and (min-width: 1800px) and (orientation: landscape) { body::before { content: "min-width: 1800px (landscape)"; background: rgba(165, 42, 42, 0.8); } }
@media all and (max-width: 1800px) and (orientation: landscape) { body::before { content: "max-width: 1800px (landscape)"; background: rgba(165, 42, 42, 0.8); } }
@chrisguitarguy
chrisguitarguy / default-author.php
Created July 2, 2012 20:07
Set a default author for posts on your WordPress site.
<?php
/*
Plugin Name: Default Author
Plugin URI: http://pmg.co
Description: Set a default author for all posts and pages
Version: 1.0
Text Domain: default-author
Author: Christopher Davis
Author URI: http://christopherdavis.me
License: GPL2