Skip to content

Instantly share code, notes, and snippets.

View derekshirk's full-sized avatar
🚙
Principal Product Designer at Driveway

Derek Shirk derekshirk

🚙
Principal Product Designer at Driveway
View GitHub Profile
@derekshirk
derekshirk / image-swap.js
Created August 26, 2019 18:10
Image Swapping with data attributes
import $ from 'jquery';
const NAME = 'swapImage';
const DATA_KEY = `decathlon.${NAME}`;
const EVENT_KEY = `.${DATA_KEY}`;
const ClassName = {
CURRENT: 'is-current',
LOADING: 'is-loading'
};
@derekshirk
derekshirk / functions.php
Last active August 10, 2016 20:06
Remove Custom Post Type (name/slug) from permalink url
/**
* Remove the slug from published post permalinks.
* Only affect our CPT though.
*/
function vipx_remove_cpt_slug( $post_link, $post, $leavename ) {
if ( ! in_array( $post->post_type, array( 'event' ) )
|| 'publish' != $post->post_status )
return $post_link;
@derekshirk
derekshirk / wordpress-better-register-cpt.php
Last active July 26, 2016 16:19
A Better Approach to Registering Custom Post Types for WordPress
<?php /*
/* ------------------------------------------------- */
/* Use Variables to Make Registering CPTs Easier
/* ------------------------------------------------- */
function register_my_cpt_name() {
$name = 'My Custom Post Type' ;
$singular = 'The Custom Post Types' ;
@derekshirk
derekshirk / acf-inline-svg.php
Created July 20, 2016 22:14
Output Inline SVGs from ACF image field
<?php
/* ————————————————————————— */
/* ACF Inline SVGs
/* ————————————————————————— */
$repeater = 'repeater_field_name'
if ( have_rows( $repeater ) ): ?>
<section class="content-main">
<div class="container"> <?php
@derekshirk
derekshirk / .bash_profile
Last active August 29, 2015 14:23
.bash_profile
# =============================================================== #
# My Personal .bash_profile
# Author: derek shirk
# Website: derekshirk.com
# Subscribe to my newsletter mergelinks.com
# =============================================================== #
# =============================================================== #
# Aliases
@derekshirk
derekshirk / git-cli-aliaes
Last active August 29, 2015 14:23
Git-CLI-Aliases
##Use cli aliases.
I love git’s cli and prefer to use it most of times while performing active operations (commit, push, checkout etc.). There is a chance that you’ll get tired of typing the same command on and on and that’s when you find your life-saver represented by git aliases.
$ git config --global alias.co "checkout"
$ git config --global alias.cmm "commit -m"
$ git config --global alias.rh "reset HEAD"
$ git config --global alias.rhh "reset HEAD --hard"'
@derekshirk
derekshirk / wp-plugin-plugin-path-helpers
Created June 12, 2015 16:32
WP-Plugin-Handy-Plugin-Path-and-URL-Helpers
<?php
$file = dirname(__FILE__) . '/your-main-plugin-file.php';
$plugin_url = plugin_dir_url($file);
$plugin_path = plugin_dir_path($file);
@derekshirk
derekshirk / gist:8206930479da994ca84a
Last active August 29, 2015 14:21
WP-Conditional_post_type_admin_screens
<?php
add_action( 'admin_enqueue_scripts', 'load_admin_custom_script' );
function load_admin_custom_script() {
$current_screen = get_current_screen();
if ( $current_screen->post_type === 'custom_post_type_name' ) {
$ss_url = get_bloginfo('stylesheet_directory');
wp_enqueue_script('jquery');
@derekshirk
derekshirk / rwd-media-queries-1
Last active August 29, 2015 14:17
rwd-media-queries-1
@media only screen and (min-width: 768px),
screen and (width:768px) and (resolution: 163dpi) {
}
@media only screen and (min-width: 960px) {
}
@derekshirk
derekshirk / WordPress-inline-svg-function
Last active August 29, 2015 14:17
WordPress-Inline-SVG-function
<?php
function grav_get_svg($svg){
$path = get_stylesheet_directory­().'/library/images­/svgs/'.$svg;
if(file_exists($path)){
return file_get_contents($path);­
} return '';
}