Skip to content

Instantly share code, notes, and snippets.

@LinzardMac
LinzardMac / grouped-input-fields
Created March 31, 2015 22:36
Reusable meta box for WordPress - Grouped input fields
Works when plugged in to custom reusable metaboxes by TammyHart
This code takes the values of THREE input fields and saves them as one meta option value. This works particularly well for time inputs where the user enters the hour, minute, and am/pm and you want to store a unix timestamp OR a 24 hour time stamp
// settings for grouped input fields
array(
'label'=> 'Start Time',
'desc' => '',
'id' => $prefix.'startselect',
'type' => 'timegroup',
'options' => array(
@LinzardMac
LinzardMac / gist:4b4bcbef09d72b777619
Created March 26, 2015 19:20
[WordPress] Override author drop down to include all users from all roles/ caps in post creation screens
/**
* override output of author drop down to include ALL user roles
*/
add_filter('wp_dropdown_users', 'include_all_users');
function include_all_users($output)
{
//set the $post global for checking user against author
global $post;
$users = get_users();
<?php
//Custom Slider
function theme_kmca_teaser_slider($atts, $content)
{
extract(shortcode_atts(array(
"class" => "",
"color" => "",
"type" => "",
"title" => "",
"subtitle" => "",
@LinzardMac
LinzardMac / gist:b6263de18e0d25ce4527
Created February 25, 2015 22:16
Pods Framework widget that gets a list of pods with or without a "featured" checkbox
class Custom_Widget_Pods_Testimonials extends WP_Widget {
public function __construct() {
$widget_ops = array('classname' => 'widget_pods_testimonials', 'description' => __( "Featured Testimonials.") );
parent::__construct('pods_testimonials', __('Featured Testimonials'), $widget_ops);
$this->alt_option_name = 'widget_pods_testimonials';
add_action( 'save_post', array($this, 'flush_widget_cache') );
add_action( 'deleted_post', array($this, 'flush_widget_cache') );
add_action( 'switch_theme', array($this, 'flush_widget_cache') );
}
var $messages = jQuery('#error-message-wrapper');
jQuery.validate({
form : '#eventsubmission',
modules : ' security',
onError : function() {
/*put fail message here */
},
modules : 'file',
decimalSeparator : '.'
});
<h1 class="day">Monday</h1>
<span class="weekdate">February 16th</span>
<article class="h-events">
<span class="time dt-start" title="2015-01-15">12:00AM</span>
<h1 class="entry-title p-name"><a href="/events/play-at-alive-5/" rel="bookmark"> PLAY AT ALIVE @ 5</a></h1>
<span class="location p-location"><a href="http://localhost:8888/gdiary/location/wilton/" rel="tag">Wilton</a> </span>
<article>
<article class="h-events">
<span class="time dt-start" title="2015-01-15">12:00AM</span>
//this collects my errors
if(!$user) {
// if the user name doesn't exist
csc_errors()->add('empty_username', __('Invalid username'), 'login');
}
if(!isset($_POST['csc_user_pass']) || $_POST['csc_user_pass'] == '') {
// if no password was entered
csc_errors()->add('empty_password', __('Please enter a password'), 'login');
}
//each call to the function has the form type in the function params
csc_show_error_messages('reg');
csc_show_error_messages('login');
csc_show_error_messages('forgot');
//set $form_type as the param
function csc_show_error_messages($form_type) {
//how do I make it so that the errors only output on the function call that has the proper form type
if($codes = csc_errors()->get_error_codes()) {
function csc_forgot_password(){
$username = trim($_POST['csc_forgot_login']);
$user_exists = false;
// First check by username
if ( username_exists( $username ) ){
$user_exists = true;
$user = get_user_by('login', $username);
}
elseif(!username_exists($username)) {
// invalid username
$prefix = 'custom_';
$custom_meta_fields = array(
array(
'label' => 'Multi-Day',
'desc' => '',
'id' => $prefix.'multiday',
'type' => 'checkbox'
),
array(
'label' => 'Recurring',