Skip to content

Instantly share code, notes, and snippets.

Adam Smith acodesmith

Block or report user

Report or block acodesmith

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
@acodesmith
acodesmith / SignalRMiddleWare.js
Created Mar 28, 2018
Redux middleware for SignalR websocket library.
View SignalRMiddleWare.js
import * as types from './state/types';
import { signalRAction } from './MessageHandler';
import {
signalRStart,
signalRTrackErrors,
signalRStop,
connection,
} from './Connection';
/**
@acodesmith
acodesmith / ReduxPromiseChain.js
Created Mar 28, 2018
Promise all response mapped to redux actions.
View ReduxPromiseChain.js
export class ReduxPromiseChain {
constructor({ dispatch, promises = [], dispatchMap = [], catchFunc }) {
this.dispatch = dispatch;
this.promises = promises;
this.dispatchMap = dispatchMap;
this.error = false;
this.catchFunc = catchFunc;
if (!dispatch && typeof dispatch === 'function') {
console.error('ReduxPromiseChain requires the dispatch function!');
@acodesmith
acodesmith / storefront-child-theme-function.php
Created Feb 19, 2018
Add version to WooCommerce Storefront Child Theme
View storefront-child-theme-function.php
<?php
add_action('wp_enqueue_scripts', function() {
global $wp_styles;
if( ! empty( $wp_styles->registered['storefront-child-style'] ) ) {
$wp_styles->registered['storefront-child-style']->ver = '0.0.1';
}
}, 40);
@acodesmith
acodesmith / filter_super_admins.php
Created Dec 18, 2017
Filter super admins from WordPress user list for multisite single site.
View filter_super_admins.php
<?php
/**
* Remove all super admins from a non-main site user list.
**/
filter_super_admins( $args ) {
global $wpdb;
if ( ! is_main_site() ) {
$user_logins = "'" . implode( "', '", get_super_admins() ) . "'";
@acodesmith
acodesmith / web-safe-fonts.json
Created Oct 31, 2017
List of web safe fonts with font stack fallback options.
View web-safe-fonts.json
{
"Arial": {
"category": "sans-serif",
"stack": [
"Arial",
"Arial",
"Helvetica",
"\"Helvetica Neue\"",
"sans-serif"
]
@acodesmith
acodesmith / taxonomy_sub_menus.php
Last active Mar 28, 2018
Sorted taxonomy list sub menu links. Each taxonomy term generates a link in the admin menu for quick sorting based on terms.
View taxonomy_sub_menus.php
<?php
add_action( 'admin_menu', 'add_taxonomy_sub_menus' );
function add_taxonomy_sub_menus()
{
$custom_post_type = 'shoes';
taxonomy_sub_menus( $custom_post_type );
}
@acodesmith
acodesmith / order_notes.php
Created Aug 25, 2017
Add Order Notes to all WooCommerce emails
View order_notes.php
<?php
function add_order_notes($order)
{
remove_filter('comments_clauses', array('WC_Comments', 'exclude_order_comments'));
$args = array(
'order' => 'DESC',
'approve' => 'approve',
'type' => 'order_note',
'post_id' => 4087
@acodesmith
acodesmith / wp-breadcrumb-home-info.php
Last active Aug 14, 2017
WordPress Breadcrumbs Data and HTML
View wp-breadcrumb-home-info.php
<?php
/**
* @return object
*/
function get_breadcrumb_home()
{
return (object) [
'post_title' => __( 'Home', 'uncg-bryan' ),
'permalink' => site_url()
];
@acodesmith
acodesmith / console.js
Created Dec 22, 2016
Example of console
View console.js
/**
* Custom Logger which only console logs to certain environment
*/
export default class Logger {
/**
* window.env var is set in the main yii2 layout
* If it's not set we default to prod
*/
constructor(options = {})
View BaseModel.php
<?php
namespace app\components;
use Yii;
/**
* Class BaseModel
* @package app\models
* @property integer created
You can’t perform that action at this time.