Skip to content

Instantly share code, notes, and snippets.

View DaveyJake's full-sized avatar
🎯
Focusing

Davey Jacobson DaveyJake

🎯
Focusing
View GitHub Profile
@DaveyJake
DaveyJake / empty.js
Last active February 20, 2023 19:24
PHP-like `empty` Function in Vanilla JS
/**
* Like PHP's {@link https://www.php.net/manual/en/function.empty.php `empty`} function in vanilla JavaScript.
*
* @author Davey Jacobson <daveyjake21 [at] geemail [dot] com>
* @since 1.0.0
* @since 1.0.1 Gist made public.
*
* @param {array|bool|number|object|string} value The value to check.
* @param {bool} [strict=false] Enable strict checking. Accepts true, false.
*
@DaveyJake
DaveyJake / _.empty.js
Last active February 20, 2023 19:19
PHP `empty` Function Using Lodash
/**
* Lodash version of PHP's `empty` function.
*
* @author Davey Jacobson <daveyjake21 [at] geemail [dot] com>
* @since 1.0.0 Initial private gist.
* @since 1.1.0 Gist made public.
* @since 1.1.1 Additional checks for 'null' and 'undefined' as strings.
* @since 1.1.2 Additional check for `NaN` and 'NaN' as a string.
*
* @param {array|bool|number|object|string} $value The value to check.
@DaveyJake
DaveyJake / allowed-post-tags.php
Last active June 17, 2021 22:13
[WP] KSES Allowed Post Tags
<?php
/**
* Found at {@link https://wp-mix.com/allowed-html-tags-wp_kses}.
*
* Note that these HTML tags and attributes go beyond those provided
* by wp_kses_post(). So if you’re looking to allow only the same tags
* that are allowed in WP Posts, just use that instead of the custom array.
*
* @author Jeff Staff
* @link https://perishablepress.com
@DaveyJake
DaveyJake / input.scss
Last active June 8, 2022 12:34
Generated by SassMeister.com.
$breakpoints: (
sm: 0em,
md: 40em
);
$types: (
m: margin,
p: padding
);
@DaveyJake
DaveyJake / class-dj-widget-skeleton.php
Last active February 24, 2021 10:11
[WP] Widget Skeleton
<?php
/**
* Widgets API: Widget Skeleton
*
* A generic skeleton template for widgets.
*
* @package Davey_Jacobson
* @subpackage Widget_Skeleton
*/
@DaveyJake
DaveyJake / is-array-associative.php
Last active February 8, 2022 03:11
[PHP] Check For Associative Array
<?php
/**
* Helper function that checks an array for string keys aka an associative array.
*
* @author Davey Jacobson <daveyjake21 [at] geemail [dot] com>
*
* @param array $array Array to check.
*
* @return bool True if associative. False if not.
*/
@DaveyJake
DaveyJake / settings.js
Last active May 23, 2020 16:53
VSCode Default Settings (JSON but named JS for syntax)
// Complete List of VSCode Defaults: https://vscode.readthedocs.io/en/latest/getstarted/settings
{
// Most Commonly Used
// Controls auto save of dirty files. Accepted values: 'off', 'afterDelay', 'onFocusChange' (editor loses focus), 'onWindowChange' (window loses focus). If set to 'afterDelay', you can configure the delay in 'files.autoSaveDelay'.
"files.autoSave": "off",
// Controls the font size in pixels.
"editor.fontSize": 14,
@DaveyJake
DaveyJake / acf-fallback-functions.php
Last active February 8, 2022 03:11
Retrieve ACF data if plugin is ever deactivated or uninstalled.
<?php
/**
* Should ACF ever become disabled or deactivated for any reason
* these functions will ensure that nothing dies in the process.
*
* These functions were inspired by {@author Steve Grunwell} and
* {@author Bill Erickson}. Their work can be viewed, respectively,
* at {@link https://stevegrunwell.com} and
* {@link https://www.billerickson.net}.
*
@DaveyJake
DaveyJake / class-dj-register-custom-taxonomy-post-type.php
Created January 25, 2020 12:15
[WP] An elongated file showing how to register a custom taxonomy and custom post type.
<?php
/**
* Developer API: Snippets for common WordPress configuration setups.
*
* IMPORTANT: You MUST defined the `const` variables in this file before
* implementing it into your current project.
*
* @link https://codex.wordpress.org/Function_Reference/register_taxonomy
* @link https://codex.wordpress.org/Function_Reference/register_post_type
*
@DaveyJake
DaveyJake / .htaccess
Last active September 12, 2019 05:48 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
# 301 Redirects for .htaccess
# Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
# Redirect an entire site:
Redirect 301 / http://www.domain.com/
# Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/