Skip to content

Instantly share code, notes, and snippets.

@alexmansfield
alexmansfield / toggle-searchform.js
Created April 23, 2016 20:35
Toggle WordPress search form on click/tab.
/**
* This assumes that the default search form is being used within an element
* with an ID of "Masthead" and that there is a menu with an ID of
* "site-navigation" that is toggled off when the search form is toggled on.
*/
jQuery( document ).ready(function( $ ) {
// Handles the focus of the search field in the header.
$( "#masthead .search-field" ).focus(function() {
@alexmansfield
alexmansfield / example-metaboxes
Created July 1, 2013 22:12
Code from meta box tutorial: http://themefoundation.com/wordpress-meta-boxes-guide/ (does not include javascritp files).
/**
* Adds a meta box to the post editing screen
*/
function example_custom_meta() {
add_meta_box( 'example_meta', 'Example Title', 'example_meta_callback', 'post' );
} // end example_custom_meta()
add_action( 'add_meta_boxes', 'example_custom_meta' );
@alexmansfield
alexmansfield / class-wp-forms.php
Created November 6, 2012 19:54
WordPress Form Classes
class THTK_Form_Input {
// Sets default form element properties
public $defaults = array(
'id' => '', // Unique element ID.
'class' => '', // Optional. CSS class names.
'title' => '', // Text to display as the input title/label.
'value' => '', // Optional. The value of the input field.
'desc' => '', // Optional. Description of form element.
'size' => 'default', // The size of the input (small, default, large; default: default).