Skip to content

Instantly share code, notes, and snippets.

Avatar
🖖

Ryan Niswonger rniswonger

🖖
View GitHub Profile
@rniswonger
rniswonger / index.html
Created November 4, 2022 16:25
HTML: Accessible title with subtitle(s)
View index.html
<!-- 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 / 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
View functions.php
add_action( 'after_setup_theme', function() {
// remove admin bar margin
add_theme_support( 'admin-bar', array( 'callback' => '__return_false' ) );
} );
@rniswonger
rniswonger / functions.php
Created July 13, 2022 16:51
WordPress: Restrict the Customizer menu search to titles
View functions.php
/**
* Restrict Customizer menu search to titles
* Based on: https://stackoverflow.com/questions/54155517/how-to-limit-wp-admin-to-search-only-titles
* Added Customizer screen detection
*/
add_filter(
'posts_search',
function( $search, $wp_query ) {
global $wp_customize;
global $wpdb;
@rniswonger
rniswonger / simple-encode-email-links--script.php
Last active March 30, 2022 17:36
PHP + JS email obfuscation
View simple-encode-email-links--script.php
@rniswonger
rniswonger / wordpress-change-admin-color-scheme-based-on-environment--functions.php
Last active March 30, 2022 17:35
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.
View wordpress-change-admin-color-scheme-based-on-environment--functions.php
/**
* Change admin color scheme based on environment for a specific user
* Color scheme options: fresh, light, modern, blue, midnight, sunrise, ectoplasm, ocean, coffee
*/
function change_color_scheme() {
$user_ids = array( 1 ); // set your user id or ids here, assuming they do not change across envs
$current_user_id = get_current_user_id();
// configure the environment addresses and their color schemes
$environments = array(
@rniswonger
rniswonger / fix-gmail-width--bookmarklet.js
Last active March 30, 2022 17:36
A bookmarklet that resize's image and table content in Gmail messages to prevent horizontal scrolling.
View fix-gmail-width--bookmarklet.js
javascript:(()=>{ document.querySelectorAll('.a3s table').forEach(item=>{item.style.width="90%"; }); document.querySelectorAll('.a3s img').forEach(item=>{item.style.maxWidth="90%";item.style.height="auto"; }); })();
@rniswonger
rniswonger / functions.php
Last active March 27, 2021 19:03
Gravity Forms: Replace the submit <input> with a <button>
View functions.php
/**
* Gravity Forms: Filters the submit button.
* Replaces the <input> button with a <button> while maintaining attributes from original <input>.
*
* @param string $button Contains the <input> tag to be filtered.
* @param object $form Contains all the properties of the current form.
*
* @return string The filtered button.
*
* GF provides sample code for doing this under Examples at the following link but this dodn't work in my environment.
@rniswonger
rniswonger / custom.css
Created October 28, 2020 22:54
Avada Theme: Equal height Content Boxes
View custom.css
/*
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;