Skip to content

Instantly share code, notes, and snippets.

View kevinwhoffman's full-sized avatar

Kevin W. Hoffman kevinwhoffman

View GitHub Profile
@tomhodgins
tomhodgins / element-query-mixin.es5.js
Last active January 7, 2018 21:37
Element Query JS-in-CSS Mixin, you supply a CSS selector, custom conditions, and a stylesheet with $this as a placeholder selector for matching elements. Use like: element('textarea', {minCharacters: 5}, `$this { background: lime; }`)
function element(selector, conditions, stylesheet) {
var features = {
minWidth: function(el, number) { return number <= el.offsetWidth },
maxWidth: function(el, number) { return number >= el.offsetWidth },
minHeight: function(el, number) { return number <= el.offsetHeight },
maxHeight: function(el, number) { return number >= el.offsetHeight },
minChildren: function(el, number) { return number <= el.children.length },
maxChildren: function(el, number) { return number >= el.children.length },
minCharacters: function(el, number) { return number <= ((el.value && el.value.length) || el.textContent.length) },
@kevinwhoffman
kevinwhoffman / resources-web-developers-designers.md
Last active January 26, 2024 21:20
Resources for Web Developers and Designers

Resources for Web Developers and Designers

This is an incomplete list of resources including courses and individuals who publish content that has helped me grow as a web developer and designer. Many of these resources are WordPress-specific as that is my current area of specialization. This list will grow over time. If you've got something to add, send me a link @kevinwhoffman and I'll check it out!

Course Providers

@ethicka
ethicka / wp-start.sh
Last active December 27, 2023 07:10
WordPress Installation with the Roots/Sage Framework and VirtualHost Creation
#!/bin/bash -e
##
# WordPress Installation and VirtualHost Creation
#
# Description: Installs a WordPress website in the ~/Sites folder, creates a homepage,
# cleans up the WP install a bit, deletes the akismet and hello dolly plugins, creates the permalinks,
# clones the roots/sage theme framework to the theme folder, deletes all the other WP default themes,
# installs/runs npm and bower and runs gulp to create the initial assets, adds a custom gitignore file
# to /wp-content, installs the roots/soil plugin, creates a git repo in wp-content, saves the WordPress
@mathetos
mathetos / plugin.php
Last active April 13, 2023 16:48
Dependent Plugin Activation/Deactivation and Alert
<?php
/*
* Dependent Plugin Activation/Deactivation
*
* Sources:
* 1. https://pippinsplugins.com/checking-dependent-plugin-active/
* 2. http://10up.com/blog/2012/wordpress-plug-in-self-deactivation/
*
*/
@dongyuwei
dongyuwei / get_title_and_url.applescript
Last active March 8, 2024 11:11 — forked from vitorgalvao/Get Title and URL.applescript
Applescript to get frontmost tab’s url and title of various browsers.
# Keep in mind that when asking for a `return` after another, only the first one will be output.
# This example is meant as a simple starting point, to show how to get the information in the simplest available way.
# Google Chrome
tell application "Google Chrome" to return URL of active tab of front window
tell application "Google Chrome" to return title of active tab of front window
# Google Chrome Canary
tell application "Google Chrome Canary" to return URL of active tab of front window
tell application "Google Chrome Canary" to return title of active tab of front window
# Chromium
@khromov
khromov / functions.php
Last active November 5, 2023 23:45
Cache a slow WP_Query in WordPress
<?php
/**
* Function that gets recent posts
*/
function get_recent_posts() {
//No cache
if(!wp_cache_get('my_complex_query_result')) {
//This is the super slow query.
@lumpysimon
lumpysimon / gist:5a68f561fd2381e64efe
Last active March 8, 2016 17:06
Example WordPress custom post type and taxonomy definitions using Extended CPTs and Extended Taxos
register_extended_post_type(
'newsletter',
array(
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => 45,
'quick_edit' => false,
'supports' => array( 'title', 'editor', 'thumbnail' ),
'admin_cols' => array(
'newsletter-image' => array(
@khromov
khromov / acf-local-json-plugin.php
Created May 7, 2015 18:44
Store Advanced Custom Field Local JSON in plugin
<?php
/*
Plugin Name: ACF Local JSON plugin
Plugin URI:
Description: Put this file in a plugin folder and create an /acf directory inside the plugin, ie: /my-plugin/acf
Author: khromov
Version: 0.1
*/
//Change ACF Local JSON save location to /acf folder inside this plugin
@dabernathy89
dabernathy89 / wp_custom_posts_navigation
Created March 17, 2015 16:39
WordPress custom posts navigation function
<?php
// Adapted from Underscores' posts navigation function
// Uses Bootstrap classes
// In a default query:
// custom_posts_navigation();
// In a custom query:
// custom_posts_navigation($my_custom_query);
@salcode
salcode / .gitignore
Last active April 3, 2024 18:38
Please see https://salferrarello.com/wordpress-gitignore/ for the canonical version of this WordPress .gitignore file. Note: I do not receive notifications for comments here (because GitHub does not send notifications on Gists)
# -----------------------------------------------------------------
# .gitignore for WordPress @salcode
# ver 20180808
#
# From the root of your project run
# curl -O https://gist.githubusercontent.com/salcode/b515f520d3f8207ecd04/raw/.gitignore
# to download this file
#
# By default all files are ignored. You'll need to whitelist
# any mu-plugins, plugins, or themes you want to include in the repo.