Skip to content

Instantly share code, notes, and snippets.

View kevinwhoffman's full-sized avatar

Kevin W. Hoffman kevinwhoffman

View GitHub Profile
@kevinwhoffman
kevinwhoffman / style.css
Created June 24, 2018 23:23
Shift Breakpoint of WP List Table
/**
* The layout of a WP List Table typically changes from a multi-column to
* single-column layout when the viewport width is less than or equal to 782px.
* This CSS shifts that breakpoint to 960px for tables with more columns that
* would otherwise become squished if they were all crammed on screen at once.
*/
@media screen and ( max-width: 960px ) {
/* WP List Table Options & Filters */
.tablenav {
@kevinwhoffman
kevinwhoffman / zap.js
Created January 31, 2018 04:25
Hourly Help Scout Unassigned Alert
fetch('https://api.helpscout.net/v1/mailboxes/{YOUR_MAILBOX_ID}/folders.json', {
headers: {
"Authorization": "Basic {YOUR_HELP_SCOUT_API_KEY}"
}
})
.then(function (res) {
return res.json();
})
.then(function (body) {
var output = {
@kevinwhoffman
kevinwhoffman / 2017-wordcamp-us-job-board.md
Last active December 9, 2018 19:09
2017 WordCamp US Job Board

The following table is a transcription of the job board at WordCamp US on December 1-3, 2017. The table includes a combination of individuals and companies that are either seeking jobs or hires related to WordPress.

Post Contact
Looking for affiliates to build church websites. aboundant.com
WordPress devs helping agencies and businesses. gtadev.ca
A full service digital agency can assist you with any of your WP needs. krishaweb.com
Web developer, WP, HTML, CSS, PHP. uark.edu
I do support. Hire me! kait.blog
I am a technical writer with WP and freelance writing experience. Nicole Plumlee Arguello, sites.uark.edu/blog
@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

@kevinwhoffman
kevinwhoffman / pre-populate-cf-field-slug.php
Created April 14, 2017 18:53
Pre-populate Caldera Forms field based on slug
<?php
/**
* Pre-populate First Name field if user is logged in.
*/
function filter_caldera_forms_render_get_field_first_name( $field, $form ) {
$current_user = wp_get_current_user();
if ( is_user_logged_in() ) {
$field['config']['default'] = $current_user->user_firstname;
}
@kevinwhoffman
kevinwhoffman / save-term-on-save-post.php
Last active April 11, 2017 06:23
Set term on save post
<?php
function prefix_set_client_id( $post_id, $post, $update ) {
$client_id_term = get_the_title( $post_id );
wp_set_object_terms( $post_id, $client_id_term, 'client_id' );
}
add_action( 'save_post_clients', 'prefix_set_client_id', 10, 3 );
@kevinwhoffman
kevinwhoffman / acf-seo-image.php
Last active November 8, 2020 18:29 — forked from bahia0019/acf-seo-image.php
For ACF users, creates an easy to use function that wraps your image in HTML5 <figure> adds <figcaption>. Also adds Schema markup in JSON LD. Parameters are 1. ACF field name, 2. Size, 3. Figure CSS class, 4. Figcaption CSS class.
function fsc_figure( $image, $size, $imageclass, $captionclass ){
/**
* Let plugins pre-filter the image meta to be able to fix inconsistencies in the stored data.
*
* @param string $image The ACF field name (i.e. 'your_photo_name').
* @param string $size Thumbnail size (i.e. 'Thumbnail', 'Medium', 'Large')
* @param string $imageclass The Figure class you want to use (ex: 'my-figure')
* @param string $captionclass The Figcaption class you want to use (ex: 'caption-blue')
*/
@kevinwhoffman
kevinwhoffman / add-styles-to-visual-editor.php
Last active January 30, 2022 14:15
Add customizer styles to visual editor
<?php
/**
* Adds styles from customizer to head of TinyMCE iframe.
* These styles are added before all other TinyMCE stylesheets.
* h/t Otto.
*/
function kwh_add_editor_style( $mceInit ) {
// This example works with Twenty Sixteen.
$background_color = get_theme_mod( 'background_color' );
$styles = '.mce-content-body { background-color: #' . $background_color . '; }';
@kevinwhoffman
kevinwhoffman / editor-styles-from-customizer.php
Last active July 14, 2016 06:15
Build editor stylesheet from customizer settings
<?php
// Place in functions.php of Twenty Sixteen to see editor background take on color of customizer background.
/**
* Build editor stylesheet from customizer settings upon customizer save.
*/
function kwh_build_stylesheet() {
$upload_dir = wp_upload_dir();
$stylesheet = $upload_dir['basedir'] . '/kwh-editor-style.css';
$styles = '';
@kevinwhoffman
kevinwhoffman / talk-submission.md
Created July 8, 2016 03:37
Demystifying Responsive Images in WordPress

Demystifying Responsive Images in WordPress

Whether you are an advanced WordPress theme developer or simply editing content from the dashboard, there is one question that everyone asks at one point or another:

What size should my images be?

This already complex question takes on a whole new dynamic with the recent addition of responsive images in WordPress 4.4. While the basic concept of responsive images may be easy to grasp, a true understanding of the inner workings is far more elusive. In this talk, we will demystify responsive images and learn how to strike a proper balance between image performance and image quality within any context.

Below is a brief overview of the main points we will touch upon throughout this talk: