Skip to content

Instantly share code, notes, and snippets.

@chrismademe
chrismademe / slideout-menu.md
Last active January 29, 2016 08:44
Create a Simple Slideout Menu for your Responsive Website

Create a Simple Slideout Menu for your Responsive Website

One of the most important parts of any site is the navigation, especially with responsive design since you don't have much space to place with. That's why I put together this super simple yet effective slide out menu, using nothing but HTML, CSS and Javascript (no jQuery here!)

The HTML

First, layout the markup for your menu.

<nav id="slideout-menu" class="slideout-menu">
@chrismademe
chrismademe / wp-wc-get-tagged-products.php
Last active June 8, 2016 15:39
Get Products with a particular Tag (WooCommerce)
<?php
// Get tagged products
$featured_products = get_posts(array(
'posts_per_page' => 3,
'post_type' => 'product',
'product_tag' => 'featured',
'orderby' => 'date'
));
@chrismademe
chrismademe / JSON.php
Last active December 23, 2017 18:25
JSON output Class
<?php
class JSON {
// Options array
private $options = array();
/**
* Construct
*
@chrismademe
chrismademe / posts-by-month.php
Created February 12, 2018 13:17
Order posts by year and month
<?php
/**
* Get Posts by Year
*
* Returns an array of posts
* sorted by year and month.
*
* @param string $post_type Post Type
* @param array $options Options array for get_posts()
@chrismademe
chrismademe / random-string.php
Created November 22, 2018 09:12
Random String in PHP
<?php
$permitted_chars = '0123456789abcdefghijklmnopqrstuvwxyz';
// Output: 54esmdr0qf
echo substr(str_shuffle($permitted_chars), 0, 10);
$permitted_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
// Output: video-g6swmAP8X5VG4jCi.mp4
echo 'video-'.substr(str_shuffle($permitted_chars), 0, 16).'.mp4';
@chrismademe
chrismademe / disable-days.js
Last active April 2, 2019 08:18
Disable days on Pikaday instance
var picker = new Pikaday({
field: document.getElementById('datpicker'),
minDate: moment().toDate(), // Today
disableDayFn: function(date) {
var currentDate, today, yearFromNow, dateFormat;
// Set Date Format
dateFormat = 'YYYY-MM-DD';
// Create Moment Objects
@chrismademe
chrismademe / get-date-range.php
Created April 9, 2019 08:26
Get range of dates in an array
<?php
/**
* Get Date Range
*
* @param string $start Start date in unix timestamp format
* @param string $end End date in unix timestamp format
* @return array Range of dates in an array
*/
function get_date_range( $start, $end ) {
@chrismademe
chrismademe / wp-post-list.php
Created June 13, 2019 08:06
WordPress Post List (Admin)
<?php
/*
* Manage Vacancies Columns
*/
add_filter( 'manage_vacancies_posts_columns', function ( $columns ) {
// Checkbox column
$cb = $columns['cb'];
@chrismademe
chrismademe / container-query.js
Created October 10, 2019 07:59
Container Query using ResizeObserver
/**
* Written by Philip Walton
* @see https://philipwalton.com/articles/responsive-components-a-solution-to-the-container-queries-problem/
*/
if ('ResizeObserver' in self) {
// Create a single ResizeObserver instance to handle all
// container elements. The instance is created with a callback,
// which is invoked as soon as an element is observed as well
@chrismademe
chrismademe / order-has-product.php
Created January 15, 2020 11:05
WooCommerce - order_has_product
<?php
/**
* Order Has Product
*
* Checks a WooCommerce order to see if it contains
* a given product ID
*
* @param object $order
* @param int $product_id