Skip to content

Instantly share code, notes, and snippets.

Devin Price devinsays

Block or report user

Report or block devinsays

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@devinsays
devinsays / svg-icon-post.md
Last active May 4, 2020
How to Use an SVG for a Custom Post Type Icon
View svg-icon-post.md

Let's use this id-card svg for the custom post type icon rather than a standard dashicon.

First, download the raw SVG file. If you open it up in a text editor, it should look something like this:

<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="id-card" class="svg-inline--fa fa-id-card fa-w-18" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path fill="currentColor" d="M528 32H48C21.5 32 0 53.5 0 80v16h576V80c0-26.5-21.5-48-48-48zM0 432c0 26.5 21.5 48 48 48h480c26.5 0 48-21.5 48-48V128H0v304zm352-232c0-4.4 3.6-8 8-8h144c4.4 0 8 3.6 8 8v16c0 4.4-3.6 8-8 8H360c-4.4 0-8-3.6-8-8v-16zm0 64c0-4.4 3.6-8 8-8h144c4.4 0 8 3.6 8 8v16c0 4.4-3.6 8-8 8H360c-4.4 0-8-3.6-8-8v-16zm0 64c0-4.4 3.6-8 8-8h144c4.4 0 8 3.6 8 8v16c0 4.4-3.6 8-8 8H360c-4.4 0-8-3.6-8-8v-16zM176 192c35.3 0 64 28.7 64 64s-28.7 64-64 64-64-28.7-64-64 28.7-64 64-64zM67.1 396.2C75.5 370.5 99.6 352 128 352h8.2c12.3 5.1 25.7 8 39.8 8s27.6-2.9 39.8-8h8.2c28.4 0 52.5 18.5
View tracking.php
<?php
/**
* Add GTM ecommerce tracking to the Order Complete (Thank You) page.
*
* @param int $order_id
*/
public function thank_you_tracking($order_id)
{
$user_id = get_current_user_id();
$is_existing_customer = $user_id ? get_user_meta($user_id, '_existing_customer', true) : false;
@devinsays
devinsays / countries.html
Created Jan 11, 2020
List of WooCommerce Countries Selected
View countries.html
<select multiple="" name="country_restriction[]" style="width:350px" data-placeholder="Choose countries…" aria-label="Country" class="wc-enhanced-select select2-hidden-accessible enhanced" tabindex="-1" aria-hidden="true">
<option selected="selected" value="AX" selected="selected">Åland Islands</option><option selected="selected" value="AF" selected="selected">Afghanistan</option><option selected="selected" value="AL">Albania</option><option selected="selected" value="DZ" selected="selected">Algeria</option><option selected="selected" value="AS">American Samoa</option><option selected="selected" value="AD">Andorra</option><option selected="selected" value="AO">Angola</option><option selected="selected" value="AI">Anguilla</option><option selected="selected" value="AQ">Antarctica</option><option selected="selected" value="AG">Antigua and Barbuda</option><option selected="selected" value="AR">Argentina</option><option selected="selected" value="AM">Armenia</option><option selected="selected" value="AW">Aruba</o
@devinsays
devinsays / okta-testing.html
Last active Nov 4, 2019
Example Okta Code for Debugging
View okta-testing.html
<html>
<head>
<title>Okta Test</title>
<!-- Latest CDN production Javascript and CSS -->
<script src="https://global.oktacdn.com/okta-signin-widget/3.2.0/js/okta-sign-in.min.js" type="text/javascript"></script>
<link href="https://global.oktacdn.com/okta-signin-widget/3.2.0/css/okta-sign-in.min.css" type="text/css" rel="stylesheet"/>
</head>
<body>
<h1>Okta Testing</h1>
@devinsays
devinsays / image-gallery-formats.php
Created Oct 6, 2019
Customized example of the Image Gallery Formats template for Portfolio Press.
View image-gallery-formats.php
View initScrollReveal.js
// Init Scroll Reveal
initScrollReveal: function() {
window.scrollreveal = ScrollReveal();
$('[data-animation]').each( function() {
var settings = {
'origin' : 'bottom',
'distance' : '0',
@devinsays
devinsays / Gruntfile.js
Created Mar 27, 2019
Updated Gruntfile.js with Working Autoprefixer
View Gruntfile.js
'use strict';
// Packages
const fiberLibrary = require('fibers');
const sassLibrary = require('node-sass');
module.exports = function(grunt) {
// load all tasks
require('load-grunt-tasks')(grunt, {scope: 'devDependencies'});
View devinsays-append-query-strings.php
<?php
function devinsays_append_query_strings( $url ) {
error_log('inital url');
error_log($url);
// If no cookie set, return.
if ( ! isset( $_COOKIE['affwp_ref'] ) ) {
return $url;
}
@devinsays
devinsays / answer.md
Created Aug 20, 2018
How to Convert a NodeList to an Array
View answer.md

Let's say you're selecting a DOM element like list items.

Option #1, use a spread:

const items = [... document.querySelectorAll('li')];

Option #2, use Array.from:

@devinsays
devinsays / timezone-laravel-fix.md
Created Jul 26, 2018
Resolving "Incorrect datetime value" in Laravel
View timezone-laravel-fix.md

While importing data into a local MySQL database in Laravel I hit this issue:

PDOException::("SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2018-03-11 02:04:15' for column 'created_at' at row 825")

The problem is due to daylight savings time (DST). In OSX MySQL is generally set to use SYSTEM time rather than UTC.

So, in my case, the issue was that datetime 2018-03-11 02:04:15 technically did not exist in CST.

You can’t perform that action at this time.