Skip to content

Instantly share code, notes, and snippets.

@stevenslack
stevenslack / settings.json
Last active Dec 16, 2021
Helpful settings for ESLint in VS Code
View settings.json
{
"[javascript]": {
"editor.rulers": [
100
],
},
"[javascriptreact]": {
"editor.rulers": [
100
],
@stevenslack
stevenslack / webpack-update-guide.md
Last active Sep 30, 2021
Webpack v4 -> v5 Update Guide
View webpack-update-guide.md

This guide is meant to serve as a reference for updating Webpack to version 5 for projects based off of the WP Starter theme using Webpack version 4. Many of the steps needed to update Webpack are not covered in the Webpack migration guide To v5 from v4 | webpack .

For the majority of the update you can use these two references:

To see what versions you are running and what the latest versions are you can run npm outdated in your terminal to see which packages need to be updated.

The sections below represent the different changes needed across your project:

View steven_slack_bio.md

Steven has spoken at numerous WordCamps on topics like information architecture and WordPress for small businesses. At Alley, he has worked on both the back end and front end of numerous projects such as Kaiser Family Foundation, Kaiser Health News, California Healthline, Streetsblog, The National Science Foundation and On Being.

View sublime.settings.json
{
"Seti_sb_tree_small": true,
"Seti_sb_wild": true,
"Seti_tabs_small": true,
"added_words":
[
"california"
],
"atomic_save": false,
"bold_folder_labels": true,
View get_terms_from_url.php
<?php
/**
* Get term object from URL
*
* Assumes the URL structure follows a standard pretty permalink eg: domain/taxonomy/term/
*
* @param string $url The URL to search for a term slug
* @param string $taxonomy_name specify a taxonomy in which the term resides
* @return object The term object
*/
@stevenslack
stevenslack / functions.php
Created Apr 26, 2016
If sidebar has a text widget with a particular shortcode
View functions.php
<?php
/**
* Check the sidebar or sidebars for a shortcode
*
* @param mixed array|string|int $index sidebar id, name, or an array of sidebar names
* @param string $shortcode the shortcode to check for
* @return bool true if the sidebar contents contains the shortcode, false otherwise
*/
function if_sidebar_has_shorcode( $index, $shortcode ) {
// get all the sidebars widgets
@stevenslack
stevenslack / wc-membership-object-ids-by-post.php
Last active Jul 19, 2018
Get the term IDs associated with the choosen membership levels assigned to a post or page. Only returns taxonomy terms.
View wc-membership-object-ids-by-post.php
<?php
/**
* Get the page/post IDs or taxonomy term IDs for restricted content
* for chosen WooCommerce Memberships levels which have been assigned to a post or page.
*
* @param string $content_type | accepts either 'taxonomy' or 'post_type' object keys
* @param int $post_id The ID of the post or page
* @return array post/pageID's or taxonomy term ID's
*/
function wc_get_membership_term_ids( $content_type, $post_id ) {
@stevenslack
stevenslack / class-drop-walker-nav.php
Last active Nov 24, 2020
WordPress Walker Nav extended to add data attributes for Drop support
View class-drop-walker-nav.php
<?php
/**
* Extends WordPress nav menu by adding data attributes and
* markup for Drop by Chris Ferdinandi
*
* Version 6.1.1
*
* drop source: https://github.com/cferdinandi/drop
*/