Skip to content

Instantly share code, notes, and snippets.

View mcaskill's full-sized avatar
🥃

Chauncey McAskill mcaskill

🥃
View GitHub Profile
@mcaskill
mcaskill / Function.Get-Var-Type.php
Last active April 13, 2020 13:07
PHP : Get the type, resource name, or class name of a variable.
<?php
if (!function_exists('get_var_type')) {
/**
* Get the type, resource name, or class name of a variable.
*
* Returns the type (name if an object or resource) of the PHP variable $var.
*
* @link http://php.net/manual/en/function.gettype.php#104224
* @param mixed $var The variable being type checked.
@mcaskill
mcaskill / charcoal.admin.elfinder.json
Last active October 7, 2016 19:46
Charcoal : Customize elFinder Connector options
{
"admin": {
"elfinder": {
"connector": {
"bind": {
"upload.pre mkdir.pre mkfile.pre rename.pre archive.pre ls.pre": [
"Plugin.Normalizer.cmdPreprocess",
"Plugin.Sanitizer.cmdPreprocess"
],
"ls": [
@mcaskill
mcaskill / charcoal-slim-polyglot.php
Created August 9, 2016 15:35
Charcoal : Adding the Slim\Polyglot middleware
<?php
/**
* Application HTTP Middlewares
*
* @link https://github.com/mcaskill/Slim-Polyglot
* @global App $app The Charcoal application.
* @package Charcoal
*/
@mcaskill
mcaskill / Function.Is-Var-Empty.php
Last active April 13, 2020 13:10
PHP : Determine whether a variable or object is empty.
<?php
if (!function_exists('is_var_empty')) {
/**
* Determine whether a variable is empty.
*
* Alternative to {@see empty()} which will resolve stringable and arrayable objects.
*
* @param mixed $var The value to be checked.
* @return boolean Returns FALSE if var exists and has a non-empty value. Otherwise returns TRUE.
@mcaskill
mcaskill / Function.OneOf.php
Last active September 10, 2018 01:49
PHP : Returns the first argument that is set and non-empty.
<?php
if (!function_exists('oneof')) {
/**
* Returns the first argument that is set and non-empty.
*
* It will guess where to stop based on the types of the arguments, e.g.
* "" has priority over array() but not 1.
*
* @link https://github.com/vito/chyrp/ Origin of function.
@mcaskill
mcaskill / Function.Fallback.php
Last active September 10, 2018 01:38
PHP : Sets a given variable if it is not set with the last parameter or the first non-empty value.
<?php
if (!function_exists('fallback')) {
/**
* Sets a given variable if it is not set.
*
* The last of the arguments or the first non-empty value will be used.
*
* @link https://github.com/vito/chyrp/ Origin of function.
* @param mixed $var The variable to return or set.
@mcaskill
mcaskill / Function.Strip-HTML.php
Last active January 4, 2022 10:38
PHP : Strip HTML and PHP tags from a string.
<?php
if (!function_exists('strip_html')) {
/**
* Strip HTML and PHP tags from a string.
*
* @param string $str The input string.
* @return string Returns the stripped string.
*/
function strip_html($str)
@mcaskill
mcaskill / Function.HTML-Build-Attributes.php
Last active January 8, 2024 04:14
PHP / WordPress : Generate a string of HTML attributes
<?php
if (!function_exists('html_build_attributes')) {
/**
* Generate a string of HTML attributes
*
* @param array $attr Associative array of attribute names and values.
* @param callable|null $callback Callback function to escape values for HTML attributes.
* Defaults to `htmlspecialchars()`.
* @return string Returns a string of HTML attributes.
@mcaskill
mcaskill / README.md
Last active January 5, 2018 15:03
Subtree split of the Sage Theme Wrapper classes (see 'roots/sage')

💀 Sage Theme Wrapper for WordPress

This gist has been deprecated and moved to a repository and published on Packagist:
mcaskill/sage-theme-wrapper

Usage

Add the following filter to your theme's functions.php:

@mcaskill
mcaskill / README.md
Last active January 5, 2018 15:01
Subtree split of the Bedrock Autoloader class (see 'roots/bedrock')

💀 Bedrock Autoloader for WordPress

This gist has been deprecated and moved to a repository and published on Packagist:
mcaskill/bedrock-autoloader

Standalone version of the Bedrock Autoloader for must-use plugins.

Usage

Add the following snippet to the mu-plugins directory (or add bedrock-autoloader.php).