Skip to content

Instantly share code, notes, and snippets.

@knolaust
knolaust / allow-svg-uploads.php
Last active January 30, 2024 14:50
Allow SVG Files Upload in WordPress
<?php
/**
* Allow SVG uploads for administrator users.
*
* This function modifies the list of allowed mime types for file uploads in WordPress.
* Specifically, it enables SVG and SVGZ file uploads for users with the 'administrator' role.
* This can enhance flexibility for site customization while maintaining security.
*
* Gist Keywords: wordpress, file upload, svg, functions, mime, security
*
@knolaust
knolaust / wp-disable-auto-update-emails.php
Last active January 30, 2024 14:50
Disable Automatic Updates Email in WordPress #wordpress, #updates, #email, #notifications
<?php
/**
* Disables automatic update notification emails in WordPress.
*
* This code snippet hooks into WordPress auto-update settings to disable
* automatic emails for core, plugin, and theme updates. It's particularly
* useful for reducing email clutter and is often suitable for a managed
* WordPress environment where updates are handled through a central management system.
*
* Gist Keywords: wordpress, emails, admin, notifications
@knolaust
knolaust / clear_sg_cache.php
Last active January 30, 2024 14:50
Clear Siteground cache for site or for single page
<?php
/**
* Clears the SiteGround cache for a specific page or the entire site.
*
* This function checks if a valid URL is provided and clears the cache
* for that specific page. If the URL is invalid or not provided, it clears
* the cache for the entire site. It relies on the 'sg_cachepress_purge_cache' function
* provided by SiteGround's caching functionality.
*
* Gist Keywords: wordpress, cache, performance, siteground
@knolaust
knolaust / ResponsiveTypeRatios.css
Last active January 30, 2024 14:51
A CSS module for fluid and responsive typography, featuring scalable text sizes based on the Golden Ratio and other typographic scales, implemented using the clamp() function for seamless readability across devices.
/**
* Typographic Scale and Font Size Variables
*
* This CSS defines a series of font scales and size variables for responsive typography.
* The scales are based on musical and mathematical ratios, with the default set to the Golden Ratio.
*
* Gist Keywords: typography, responsive, responsiveness, css, variables, custom properties
* Author: Knol Aust
*/
@knolaust
knolaust / add_slug_to_body.php
Last active January 30, 2024 14:51
Add Page/Post slug to body class in WordPress
<?php
/**
* Adds the current page or post slug as a class to the body tag in WordPress.
*
* This function is useful for applying page-specific CSS styles. It checks if
* the current view is a singular page and then adds the post's slug as a class
* to the body tag, making it easier to target with CSS.
*
* Gist Keywords: wordpress, theme, slug, css, body class
*
@knolaust
knolaust / siteground-anticache.txt
Last active January 30, 2024 14:52
SiteGround anti-cache for directory — place in .htaccess within directory and SiteGround won't cache.
# Begin SiteGround Anti-Cache Configuration for Directory
# Author: Knol Aust
# Gist Keywords: siteground, caching, htaccess, performance
# This configuration is intended for use within a specific directory on a SiteGround-hosted website.
# Placing this .htaccess file in a directory will instruct SiteGround's caching mechanisms
# not to cache any content from this directory. This can be particularly useful for directories
# containing dynamic or frequently updated content, where caching might lead to stale content being served.
<IfModule mod_headers.c>
@knolaust
knolaust / redirect_authors.php
Last active January 30, 2024 14:52
Redirect Wordpress Author Pages to Home
<?php
/**
* Redirect Author Page to Home
*
* Gist Keywords: wordpress, author page, redirect
* Author: Knol Aust
* Version: 1.0.0
*
* This function redirects the Author Page to the home page with a 301 permanent redirect.
*/
@knolaust
knolaust / enqueue.php
Last active January 30, 2024 14:53
Enqueue example for WordPress with filemtime
<?php
/**
* Enqueue Styles and Scripts for My Theme
*
* This function enqueues styles and scripts for the custom theme.
* It includes versioning based on the file's last modification time
* to prevent caching and ensures proper dependencies.
*
* Gist Keywords: wordpress, theme, javascript, styles, enqueue
*
@knolaust
knolaust / gutenberg_colors.scss
Last active January 30, 2024 14:54
Generate Colors for Gutenberg with SCSS
/**
* Custom SCSS Variables and Class Generators
*
* This SCSS file defines custom variables for colors and generates classes
* for applying these colors to text, backgrounds, and borders. Additionally,
* it generates classes for font sizes based on predefined sizes in 'rem' units.
*
* Gist Keywords: scss, sass, variables, colors, font sizes, gutenberg, editor, styles
*
* @author Knol Aust
@knolaust
knolaust / msCounties.json
Last active January 19, 2024 15:43
All Mississippi Counties in JSON
{
"ms_counties": [
"Adams",
"Alcorn",
"Amite",
"Attala",
"Benton",
"Bolivar",
"Calhoun",
"Carroll",