Skip to content

Instantly share code, notes, and snippets.

View acodesmith's full-sized avatar
💯

Adam Smith acodesmith

💯
View GitHub Profile
@acodesmith
acodesmith / wp-breadcrumb-home-info.php
Last active August 14, 2017 14:11
WordPress Breadcrumbs Data and HTML
<?php
/**
* @return object
*/
function get_breadcrumb_home()
{
return (object) [
'post_title' => __( 'Home', 'uncg-bryan' ),
'permalink' => site_url()
];
@acodesmith
acodesmith / console.js
Created December 22, 2016 16:49
Example of console
/**
* 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 = {})
<?php
namespace app\components;
use Yii;
/**
* Class BaseModel
* @package app\models
* @property integer created
<?php
namespace app\components;
class Statuses {
/**
* ====================
* STATUS TYPES
* ====================
@acodesmith
acodesmith / webpack.example.config.js
Last active December 14, 2016 19:43
Example Webpack
//Webpack and NPM plugins
var webpack = require('webpack');
var glob = require("glob");
var path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
//Folder Locations
var APP_DIR = path.resolve(__dirname, 'src');
var BUILD_DIR = path.resolve(__dirname, 'dist');
@acodesmith
acodesmith / Products.php
Last active February 9, 2018 16:04
Example of advanced relationships in Yii2
<?php
/**
* @return \yii\db\ActiveQuery
*/
public function getProduct_variants()
{
return $this->hasMany(ProductVariants::className(), ['product_id' => 'id'])->andWhere(['<>','product_variants.status', Statuses::STATUS_REMOVED]);
}
/**
Template.restaurant.onCreated(function() {
let restaurantSub = this.subscribe( 'Restaurant', [ FlowRouter.getParam('restaurantId') ] )
, restaurantPromise = restaurantSub.readyPromise()
this.restaurant = new ReactiveVar()
this.ready = new ReactiveVar( false )
restaurantPromise.then(function(){
@acodesmith
acodesmith / spacing.scss
Created February 17, 2016 17:48
Standardize SCSS spacing extenders.
/**
* Variables
*/
$space: 20px !default;
$space-tiny: ($space / 4) !default; // ~5px
$space-small: ($space / 2) !default; // ~10px
$space-medium: ($space * 1.5) !default; // ~30px
$space-large: ($space * 2) !default; // ~40px
$space-huge: ($space * 3) !default; // ~60px
$directions: right, left;
$sizes: xs, sm, md, lg;
@each $direction in $directions {
@each $size in $sizes {
.pull-#{$direction}-#{$size}{
@if($size == xs){
@media (min-width: $screen-xs-min) {
@acodesmith
acodesmith / srcset-shortcode-wordpress.php
Created July 26, 2015 03:13
srcset shortcode function for wordpress - returns srcset from image attachment id
add_shortcode('srcset', 'srcset_func');
function srcset_func($attr)
{
$images = array();
foreach(get_intermediate_image_sizes() as $size){
$images[] = wp_get_attachment_image_src($attr['attachment_id'], $size);
}
$srcset = ''; $count = 0;