Skip to content

Instantly share code, notes, and snippets.

View laurelstreng's full-sized avatar

Laurel laurelstreng

View GitHub Profile
@laurelstreng
laurelstreng / deactivate-plugins.php
Created June 1, 2020 15:19
Wordpress mu-plugin to deactivate specific plugins on your local environment if defined in a wp-config-local.php file.
<?php
/*
Plugin Name: Deactivate Plugins Locally
Description: Deactivate specific plugins on your local environment if defined in a wp-config-local.php file.
Version: 1.0
*/
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
if ( defined( 'LOCAL_DISABLED_PLUGINS' ) ) { // If defined in wp-config-local.php
$plugins_to_disable = unserialize( LOCAL_DISABLED_PLUGINS );
@laurelstreng
laurelstreng / functions.php
Last active July 22, 2020 14:11
If using the Wordpress author template to show user posts, change the main query via the pre_get_posts filter hook to show all types of posts by the author.
<?php
function lstreng_author_any_post_types $query ) {
// apply changes only for author archive page
if ( ! is_author() || ! $query->is_main_query() )
return;
$query->set('post_type', 'any');
}
add_action( 'pre_get_posts', 'lstreng_author_any_post_types' );
@laurelstreng
laurelstreng / functions.php
Last active September 3, 2020 15:50
Function to update all Gravity Forms 'State' dropdown field from full state name values to abbreviated state values.
<?php
/**
* Function to update all Gravity Forms 'State' dropdown field (based on field id #6), from full state name values to abbreviated state values if logged into the site.
* Use once, then remove the code.
*/
function lstreng_update_all_gravity_forms() {
// only load for admin panel
if ( is_admin() ) {
// load all forms
$forms = GFAPI::get_forms();
@laurelstreng
laurelstreng / style.css
Created December 9, 2024 12:56
CSS – Dark Mode
/**
* CSS Dark Mode
*
* Declare color-scheme: light dark in the :root.
* Then use the light-dark() function to set both colors.
**/
:root {
color-scheme: light dark;
--bg-color: light-dark(white, black);
@laurelstreng
laurelstreng / pseudo-alt-text.css
Created March 6, 2025 15:18
Add alternative text to pseudo elements
/**
* Adding alternative text for screen readers to pseudo elements.
*
* https://developer.mozilla.org/en-US/docs/Web/CSS/content#adding_an_image_with_alternative_text
**/
.location {
&::before {
/* fallback content */
content: url(images/backgrounds/location.svg) ' - Alt text is not supported';