Skip to content

Instantly share code, notes, and snippets.

/**
* Return a timestamp with the format "m/d/yy h:MM:ss TT"
* @type {Date}
*/
function timeStamp() {
// Create a date object with the current time
var now = new Date();
// Create an array with the current month, day and time
// Remove classes that have given prefix
// Example:
// You have an element with classes "apple juiceSmall juiceBig banana"
// You run:
// $elem.removeClassPrefix('juice');
// The resulting classes are "apple banana"
// NOTE: discussion of implementation techniques for this, including why simple RegExp with word boundaries isn't correct:
// http://stackoverflow.com/questions/57812/jquery-remove-all-classes-that-begin-with-a-certain-string#comment14232343_58533
@cdillon
cdillon / gist:59033a52ba9796930e6e
Created April 22, 2015 23:30
require minimum length for WordPress user login
/**
* Additional registration checks.
*
* This filter is documented in wp-includes/user.php
*/
function my_registration_errors( $errors, $sanitized_user_login, $user_email ) {
if ( strlen( $sanitized_user_login ) < 5 ) {
$errors->add( 'username_too_short', __( '<strong>ERROR</strong>: Username must be at least 5 characters.' ) );
}
return $errors;
@cdillon
cdillon / theme-screenshot-inheritance.php
Last active November 15, 2015 19:17
A minimalist WordPress plugin to allow child themes to inherit their parent's screenshot.
<?php
/**
* Plugin Name: Theme Screenshot Inheritance
* Description: Child themes without screenshots inherit their parent theme's screenshot.
*
* Drop this in the /plugins or /mu-plugins directory.
*/
/**
* Add parent screenshot to child theme.
<?php
/* Register custom post types on the 'init' hook. */
add_action( 'init', 'my_register_post_types' );
/**
* Registers post types needed by the plugin.
*
* @since 0.1.0
* @access public
@cdillon
cdillon / wpmtst_get_the_category_list.php
Created January 19, 2016 12:39
Use in place of `get_the_category_list` in your single-wpm-testimonial.php template file.
/**
* Retrieve category list in either HTML list or custom format.
* This is a copy of the native `get_the_category_list` function.
*
* @global WP_Rewrite $wp_rewrite
*
* @param string $separator Optional, default is empty string. Separator for between the categories.
* @param string $parents Optional. How to display the parents.
* @param int|bool $post_id Optional. Post ID to retrieve categories.
* @return string
@cdillon
cdillon / sc_our_services_admin.css
Created April 9, 2016 21:29
To fix a simple CSS conflict caused by the [Our Services Showcase] WordPress plugin version 2.0. In the plugin's "inc/style" directory, replace the file "sc_our_services_admin.css" with this.
/*
Document : sc_our_services_admin
Created on : Jun 25, 2014, 10:07:44 PM
Author : Bilal
Description:
Purpose of the stylesheet follows.
*/
root {
display: block;
<?php
/**
* Strong Testimonials - Single post section
*
* For Spacious theme by ThemeGrill
*/
?>
<?php get_header(); ?>
<?php
/**
* Strong Testimonials - Single testimonial content
*
* For Spacious theme by ThemeGrill
*/
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php do_action( 'spacious_before_post_content' ); ?>