Skip to content

Instantly share code, notes, and snippets.

View kevindees's full-sized avatar
🎯
Focusing

Kevin Dees kevindees

🎯
Focusing
View GitHub Profile
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
ssl_certificate /usr/local/etc/nginx/ssl/{{host}}.crt;
ssl_certificate_key /usr/local/etc/nginx/ssl/{{host}}.key;
ssl_ciphers HIGH:!aNULL:!MD5;
# listen 80;

About

If you ever wanted MVC for your WordPress theme's template files without a framework or reduced WordPress performance. If you ever wanted to register template files like single.php, index.php, page.php, and so forth in PHP instead of creating them as files in your theme. All you need is a blank index.php file and a few lines of code.

Getting Started

Add these classes to your WordPress site (in your functions.php file is just fine). Then add the following to your theme after creating a blank index.php file (must be blank) in your theme:

$override = new TemplateOverride(__DIR__ . '/index.php');
<?php
class Nil implements ArrayAccess
{
/** @var mixed */
protected $value;
/**
* @param mixed $value
*
@kevindees
kevindees / helpers-grid.scss
Last active July 31, 2019 17:41
Simple grid css with flex fallback
$cols: 12;
$gutter: 20px;
// flex fallback
.grid-columns {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
width: 100%;
@kevindees
kevindees / helpers-empty.php
Created May 21, 2019 15:05
Helpers when using using empty()
<?php
// do. if( empty_or($data['name'], $data['value']) )
// vs. if( !empty($data['name']) || !empty($data['value']) )
function empty_or(...$args) {
foreach ($args as $arg) {
if(empty($arg)) { return true; }
}
return false;
@kevindees
kevindees / methods.scss
Last active May 27, 2021 19:00
SVG SCSS/SASS Background Image URL Encode
// Replace letters
@function str-replace($string, $search, $replace: '') {
$index: str-index($string, $search);
@if $index {
@return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
}
@return $string;
}
# IDE generated files #
#######################
.idea
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
<?php
function array_reduce_allowed_str($array) {
$reduced = '';
array_walk($array, function($val, $key) use(&$reduced) {
$reduced .= $val ? " $key" : '';
});
$cleaned = implode(' ', array_unique(array_map('trim', explode(' ', trim($reduced)))));
return $cleaned;
}
@kevindees
kevindees / common_bash.sh
Created September 19, 2018 18:15
common_bash
# laravel
alias art='php artisan'
# basic
alias lf="ls -AF"
alias _='sudo'
alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'
alias copyssh="pbcopy < $HOME/.ssh/id_rsa.pub"
alias reloadcli="source $HOME/.zshrc"
@kevindees
kevindees / replace-wp-dashboard.php
Created July 27, 2018 14:33 — forked from wpscholar/replace-wp-dashboard.php
Replace the default WordPress dashboard with a custom one
<?php
/**
* Plugin Name: Replace WordPress Dashboard
* Description: Replaces the default WordPress dashboard with a custom one.
* Author: Micah Wood
* Author URI: http://micahwood.me
* Version: 0.1
* License: GPL3
*/