Skip to content

Instantly share code, notes, and snippets.

Avatar

Controlled Chaos Design ControlledChaos

View GitHub Profile
@ControlledChaos
ControlledChaos / gist:2b817720fb3209777064228d00d6ed68
Created Mar 24, 2021 — forked from danielbachhuber/gist:7126249
Include posts from authors in the search results where either their display name or user login matches the query string
View gist:2b817720fb3209777064228d00d6ed68
<?php
/**
* Include posts from authors in the search results where
* either their display name or user login matches the query string
*
* @author danielbachhuber
*/
add_filter( 'posts_search', 'db_filter_authors_search' );
function db_filter_authors_search( $posts_search ) {
@ControlledChaos
ControlledChaos / functions.php
Created Jan 1, 2021 — forked from tripflex/functions.php
WordPress Remove Filter (remove_filter converted to remove_class_filter) to remove Filter/Action without Class Object access. Works with WordPress 1.2+ (4.7+ support added 9-19-2016)
View functions.php
<?php
/**
* Make sure the function does not exist before defining it
*/
if( ! function_exists( 'remove_class_filter' ) ){
/**
* Remove Class Filter Without Access to Class Object
*
* In order to use the core WordPress remove_filter() on a filter added with the callback
@ControlledChaos
ControlledChaos / php-style-guide.md
Created Dec 24, 2020 — forked from ryansechrest/php-style-guide.md
PHP style guide with coding standards and best practices.
View php-style-guide.md

PHP Style Guide

All rules and guidelines in this document apply to PHP files unless otherwise noted. References to PHP/HTML files can be interpreted as files that primarily contain HTML, but use PHP for templating purposes.

The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Most sections are broken up into two parts:

  1. Overview of all rules with a quick example
  2. Each rule called out with examples of do's and don'ts
@ControlledChaos
ControlledChaos / whichones.js
Created Dec 23, 2020 — forked from scottjehl/whichones.js
which elements are wider than the viewport?
View whichones.js
var list = [];
document.querySelectorAll("body *")
.forEach(function(elem){
if(elem.getBoundingClientRect().width > document.body.getBoundingClientRect().width){
list.push(elem.outerHTML.split('>')[0] + '>');
}
});
confirm( "these elements are wider than the viewport:\n\n " + list.join("\n") )
@ControlledChaos
ControlledChaos / ExtendedReflectionClass.php
Created Dec 12, 2020 — forked from Zeronights/ExtendedReflectionClass.php
PHP: Getting use statements and aliases from class
View ExtendedReflectionClass.php
<?php
/**
* The MIT License (MIT)
*
* Copyright (c) Ozgur (Ozzy) Giritli <ozgur@zeronights.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
@ControlledChaos
ControlledChaos / easings.css
Created Jul 21, 2020 — forked from argyleink/easings.css
Handy CSS properties for easing functions
View easings.css
:root {
--ease-in-quad: cubic-bezier(0.55, 0.085, 0.68, 0.53);
--ease-in-cubic: cubic-bezier(0.55, 0.055, 0.675, 0.19);
--ease-in-quart: cubic-bezier(0.895, 0.03, 0.685, 0.22);
--ease-in-quint: cubic-bezier(0.755, 0.05, 0.855, 0.06);
--ease-in-expo: cubic-bezier(0.95, 0.05, 0.795, 0.035);
--ease-in-circ: cubic-bezier(0.6, 0.04, 0.98, 0.335);
--ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);
--ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1);
--ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1);
@ControlledChaos
ControlledChaos / autoload.php
Created Jan 28, 2020 — forked from sheabunge/autoload.php
Basic PHP class autoloader that follows the WordPress coding standards for class names and class filenames
View autoload.php
<?php
namespace Shea\Example_Plugin;
/**
* Enable autoloading of plugin classes in namespace
* @param $class_name
*/
function autoload( $class_name ) {
@ControlledChaos
ControlledChaos / WP Customizer - URL
Created Jan 19, 2020 — forked from ajskelton/WP Customizer - URL
Add a URL field to the WordPress Customizer.
View WP Customizer - URL
$wp_customize->add_setting( 'themeslug_url_setting_id', array(
'capability' => 'edit_theme_options',
'sanitize_callback' => 'themeslug_sanitize_url',
) );
$wp_customize->add_control( 'themeslug_url_setting_id', array(
'type' => 'url',
'section' => 'custom_section', // Add a default or your own section
'label' => __( 'Custom URL' ),
'description' => __( 'This is a custom url input.' ),
@ControlledChaos
ControlledChaos / font-stacks.css
Created Oct 10, 2019 — forked from don1138/font-stacks.css
CSS Modern Font Stacks
View font-stacks.css
/* Modern Font Stacks */
/* System */
font-family: system, -apple-system, ".SFNSText-Regular", "San Francisco", "Roboto", "Segoe UI", "Helvetica Neue", "Lucida Grande", sans-serif;
/* Times New Roman-based serif */
font-family: Cambria, "Hoefler Text", Utopia, "Liberation Serif", "Nimbus Roman No9 L Regular", Times, "Times New Roman", serif;
/* A modern Georgia-based serif */
font-family: Constantia, "Lucida Bright", Lucidabright, "Lucida Serif", Lucida, "DejaVu Serif", "Bitstream Vera Serif", "Liberation Serif", Georgia, serif;
@ControlledChaos
ControlledChaos / wp-get-image-sizes.php
Created Sep 7, 2019 — forked from eduardozulian/wp-get-image-sizes.php
Get all the registered image sizes along with their dimensions
View wp-get-image-sizes.php
<?php
/**
* Get all the registered image sizes along with their dimensions
*
* @global array $_wp_additional_image_sizes
*
* @link http://core.trac.wordpress.org/ticket/18947 Reference ticket
* @return array $image_sizes The image sizes
*/
function _get_all_image_sizes() {