Skip to content

Instantly share code, notes, and snippets.

View rniswonger's full-sized avatar
🖖

Ryan Niswonger rniswonger

🖖
View GitHub Profile
@rniswonger
rniswonger / functions.php
Last active September 20, 2022 17:50
WordPress: A Better Admin Bar - hide the admin bar in desktop behind a tab and reveal on hover/focus
add_action( 'after_setup_theme', function() {
// remove admin bar margin
add_theme_support( 'admin-bar', array( 'callback' => '__return_false' ) );
} );
@rniswonger
rniswonger / index.html
Created November 4, 2022 16:25
HTML: Accessible title with subtitle(s)
<!-- From https://www.tpgi.com/subheadings-subtitles-alternative-titles-and-taglines-in-html/ -->
<hgroup role="group" aria-roledescription="Heading group">
<p aria-roledescription="subtitle">Subtitle 1</p>
<h1>Title</h1>
<p aria-roledescription="subtitle">Subtitle 2</p>
</hgroup>
@rniswonger
rniswonger / wordpress-plugin-activation-based-on-environment--functions.php
Last active February 4, 2023 17:57
WordPress: Disable/activate plugins in development environment
<?php
/**
* Setup development environment by manipulating plugin activation
* Replace the dev URLs and plugin paths accordingly
*/
function mysite_development_environment_setup() {
// define the development sites
$dev_envs = array(
'http://localhost:8888',
@rniswonger
rniswonger / svg-url.scss
Created October 7, 2017 22:07
SASS Mixin: Generate background-image using raw SVG
// Function to create an optimized svg url
// http://codepen.io/jakob-e/pen/doMoML
@function svg-url($svg) {
// Chunk up string in order to avoid "stack level too deep" error
$encoded: '';
$slice: 2000;
$index: 0;
$loops: ceil(str-length($svg)/$slice);
@for $i from 1 through $loops {
$chunk: str-slice($svg, $index, $index + $slice - 1);
@rniswonger
rniswonger / 7zip-all-subfolders.bat
Created November 9, 2019 22:44
Use 7zip to archive all subfolders in their own zip file
for /d %%X in (*) do "c:\Program Files\7-Zip\7z.exe" a "%%X.zip" "%%X\"
@rniswonger
rniswonger / wordpress-change-admin-color-scheme-based-on-environment--functions.php
Last active July 21, 2023 17:45
WordPress: Change admin color scheme based on environment and user. Because I got tired of doing it manually when I re-cloned my local/staging db.
/**
* Change admin color scheme for specific users based on the environment type. Overrides user selection.
* Color scheme options: fresh, light, modern, blue, midnight, sunrise, ectoplasm, ocean, coffee
*/
add_filter(
'admin_init',
function () {
$user_ids = array( 1 ); // Array of user IDs
$current_user_id = get_current_user_id();
@rniswonger
rniswonger / bookmarklet-fix-gmail-desktop-annoyances.js
Last active August 24, 2023 16:47
A bookmarklet that resizes image and table content in Gmail messages to prevent horizontal scrolling.
javascript: (() => { let style = document.createElement("style"); style.innerHTML = ` .a3s table { width: 90% !important; } .a3s img { max-width: 90% !important; height: auto !important; } tr:has(.ast) { display: none !important; } `; document.head.appendChild(style);})();
@rniswonger
rniswonger / wp-disable-plugin-update.php
Last active January 3, 2024 15:21
WordPress - Disable specific plugin update check
/**
* Prevent update notification for plugin
* http://www.thecreativedev.com/disable-updates-for-specific-plugin-in-wordpress/
* Place in theme functions.php or at bottom of wp-config.php
*/
function disable_plugin_updates( $value ) {
if ( isset($value) && is_object($value) ) {
if ( isset( $value->response['plugin-folder/plugin.php'] ) ) {
unset( $value->response['plugin-folder/plugin.php'] );
}
@rniswonger
rniswonger / custom.css
Created October 28, 2020 22:54
Avada Theme: Equal height Content Boxes
/*
Add this code to the Avada Custom CSS.
Add the class "equal-height" to your Content Boxes Options container, not a single Content Box.
The editor preview will not show the change but reload the live page to see the results.
*/
.fusion-content-boxes.equal-height {
display: flex;
align-items: stretch;
flex-wrap: wrap;
@rniswonger
rniswonger / fluid-text.scss
Last active April 19, 2024 14:39
Sass Mixin: Fluid Text
// fluidly resize type
// based on example here https://css-tricks.com/snippets/css/fluid-typography/
@mixin fluid-type($font-min, $font-max, $screen-min, $screen-max) {
font-size: #{$font-min}px;
@media only screen and (min-width: #{$screen-min}px) {
font-size: calc(
#{$font-min}px + #{($font-max - $font-min)} * (100vw - #{$screen-min}px) / (#{$screen-max} - #{$screen-min})
);
}