Skip to content

Instantly share code, notes, and snippets.

@gyrus
gyrus / mc_signup.php
Created May 8, 2013 20:12
Minimal MailChimp custom form (for a WordPress template)
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="[grab the URL from the MC form builder]" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate">
<div id="field-firstname" class="field">
<label for="mce-FNAME" class="assistive-text"><?php _e( 'First name' ); ?></label>
<input type="text" value="" name="FNAME" class="input" id="mce-FNAME" placeholder="<?php _e( 'First name' ); ?>">
</div>
<div id="field-lastname" class="field">
<label for="mce-LNAME" class="assistive-text"><?php _e( 'Last name' ); ?></label>
<input type="text" value="" name="LNAME" class="input" id="mce-LNAME" placeholder="<?php _e( 'Last name' ); ?>">
@gyrus
gyrus / cached_data.php
Last active December 14, 2015 13:29
Generic WordPress caching with Transients API
<?php
/**
* Get data with caching
*
* Change function name, transient name, and cache timeout if necessary.
* Populate $my_data, obviously.
* "refresh" query parameter useful for manual refreshing.
*/
function pilau_get_my_data() {
@gyrus
gyrus / first_para_class.php
Last active December 14, 2015 03:18
Output WordPress content with a class on the first para
<?php
/**
* Output content with a class on the first para
*
* @param string $class Default: 'intro'
* @return void
*/
function pilau_the_content_first_para_class( $class = 'intro' ) {
$content = apply_filters( 'the_content', get_the_content() );
@gyrus
gyrus / carousel.js
Last active December 12, 2015 04:29
A sophisticated carousel system for use with the Pilau Starter theme (https://github.com/pilau/starter). Also dependent on the Developer's Custom Fields plugin (https://github.com/gyrus/WordPress-Developers-Custom-Fields). Successfully tested, but there may be some glitches to iron out in integrating - it was developed for one project and never …
<?php
/*
Plugin Name: l3rady's CPT Structure Helper
Plugin URI: http://l3rady.com/projects/l3rady-cpt-structure-helper/
Description:
Author: Scott Cariss
Version: 0.2.1
Author URI: http://l3rady.com/
Text Domain: sccptshelper
Domain Path: /languages
@gyrus
gyrus / pilau-tabs.css
Created August 14, 2012 12:20
WordPress tabs shortcode
/*
* This is the bare minimum CSS necessary to make jQuery UI tabs "work".
* Obviously you'll need to do a lot more styling to make them "good" :)
*/
.ui-tabs-hide { display: none; }
@gyrus
gyrus / gist:3339396
Last active October 8, 2015 13:37
WordPress Widget Logic plugin code generator
<?php
/*
These days I prefer the Dynamic Widgets plugin (http://wordpress.org/extend/plugins/dynamic-widgets/), because
it can accommodate sophisticated widget display rules in a GUI that clients can use. However, the Widget Logic
plugin (http://wordpress.org/extend/plugins/widget-logic/) still has its place. This bit of code will add
a "Widget Logic generator" to the Widgets page, which is useful if you use this plugin and have some users
who aren't comfortable with writing the simple PHP.
@gyrus
gyrus / gist:3332597
Created August 12, 2012 16:19
Override a WordPress 404 with a specific template
<?php
/**
* Override a 404
*
* @param string $template If passed, this template will be included and
* the request will be terminated if the inclusion
* was successful
* @param string $type If not a 404, what type of request should this be
* flagged as? Must correspond to one of the
@gyrus
gyrus / gist:3189303
Created July 27, 2012 17:41
Make containing elements into links
/**
* Make containing elements into links
*
* jQuery, in conjunction with two CSS classes:
*
* 'make-link' - Makes containing elements into links. Add the class '.make-link-target'
* to the descendant anchor that is linked to the URL you want the ancestor element to
* link to. The JS handles making the cursor into a pointer and adds the class 'hover'
* to the target anchor when the ancestor is hovered.
*