Skip to content

Instantly share code, notes, and snippets.

View kevinwhoffman's full-sized avatar

Kevin W. Hoffman kevinwhoffman

View GitHub Profile
@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);
@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
@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(
@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) },
@nicomollet
nicomollet / wp_auto_install.sh
Last active June 8, 2022 19:10
WP-CLI auto install script
#!/bin/bash
# Default options
LOCALE="fr_FR"
DB_HOST='localhost'
VIRUSTOTAL_KEY='YOUR_KEY'
printf "Name of the project? cf My Project: "
read PROJECT_NAME
@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/
*
*/
@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.
@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
@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

@joyrexus
joyrexus / README.md
Last active February 19, 2024 17:15 — forked from liamcurry/gist:2597326
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})