Skip to content

Instantly share code, notes, and snippets.

@knolaust
knolaust / sass-aspect-ratio-with-fallback.scss
Last active January 30, 2024 14:55
Sass Mixin For CSS Aspect-Ratio With Fallback
/**
* Include this Sass mixin for aspect-ratio. Includes fallback
* for browsers that do not support aspect-ratio. This fallback is really not necessary at this point unless
* a specific browser you need to support.
*
* Usage:
* @include aspect-ratio(16,9);
* creates a 16x9 container using aspect-ratio for supported browsers with fallback for browsers that do not.
*
* Codepen Example: https://codepen.io/knolaust/pen/KKZwXjv
@knolaust
knolaust / custom_tinymce_colorpicker.php
Last active June 7, 2024 20:39
Override TinyMCE's default colors. Created specifically for Classic Editor Block or ACF WYSIWYG in WordPress.
<?php
/**
* Limit MCE WYSIWYG Colors
*
* This function overrides TinyMCE's default color options in the WordPress Classic Editor Block
* or ACF (Advanced Custom Fields) WYSIWYG editor. It limits the available color choices.
*
* Gist Keywords: wordpress, editor, admin, tinymce, colors
* Author: Knol Aust
* Version: 1.0.0
@knolaust
knolaust / hide_content_editor.php
Last active January 30, 2024 14:56
Hide content editor on specific pages. Useful for ACF.
<?php
/**
* Hide Content Editors on Specific Pages
*
* This function hides the content editor on specific pages in the WordPress admin panel.
* It checks the current page and removes the editor for pages with specific titles.
*
* Gist Keywords: wordpress, editor, acf, content
* Author: Knol Aust
* Version: 1.0.0
@knolaust
knolaust / acf_cpt_options.php
Last active January 30, 2024 14:57
Adds an "options" page for a Custom Post Type and ACF
<?php
/**
* Add Options Page for Custom Post Type and ACF
*
* Adds an "options" page for a custom post type and Advanced Custom Fields (ACF).
* It allows you to define custom options specific to the post type.
*
* Gist Keywords: wordpress, acf, cpt, custom post type, options
* Author: Knol Aust
*/
@knolaust
knolaust / location_outline_gmap.html
Last active January 30, 2024 14:57
Add a city, county, state overlay to Google Map
<!--
To get the OSM ID for a county or municipality:
1. Go to https://nominatim.openstreetmap.org/ui/search.html
2. Search for the county or municipality.
3. Click on "Details" and scroll to the OSM ID. Copy it.
4. Go to http://polygons.openstreetmap.fr/index.py and paste the OSM ID.
5. Copy the coordinates and remove unnecessary array wrappers.
Author: Knol Aust
Gist Keywords: google, maps, js, javascript, css
-->
@knolaust
knolaust / gzip-comporession-for-wordpress.php
Last active January 30, 2024 14:58
gzip Compression for WordPress
<?php
/**
* Enable GZIP compression for HTML, CSS, JavaScript, Text, XML, and fonts.
*
* This code snippet configures the server to enable GZIP compression for various file types,
* including HTML, CSS, JavaScript, Text, XML, and font files. It also includes rules to handle
* browser compatibility issues.
*
* Gist Keywords: wordpress, gzip, server optimization, speed, compression
*
@knolaust
knolaust / cf7-hide_recaptcha.php
Last active January 30, 2024 14:59
Hide ReCaptcha overlay when page does not contain Contact Form 7 form.
<?php
/**
* Hide Contact Form 7 reCAPTCHA on non-contact pages.
*
* This function removes the enqueuing of Contact Form 7's reCAPTCHA scripts
* on pages that don't contain the Contact Form 7 shortcode. It helps optimize
* website performance by only loading necessary scripts when needed.
*
* Gist Keywords: wordpress, recaptcha, cf7, contact gorm 7, performance
*
@knolaust
knolaust / console_log_ACF.php
Last active January 30, 2024 15:00
Output Advanced Custom Fields Data as JSON in JavaScript Console
<?php
/**
* Output Advanced Custom Fields Data as JSON in JavaScript Console.
*
* This code retrieves data from Advanced Custom Fields (ACF) and outputs it
* as JSON in the JavaScript console for debugging and development purposes.
*
* Gist Keywords: wordpress, acf, javascript, debugging
*
* @author Knol Aust
@knolaust
knolaust / xhr.js
Last active January 30, 2024 15:00
JavaScript xhr Request
/**
* JavaScript Request with Error Handling
* Author: Knol Aust
* Gist Keywords: js, javascript, http request, error handling
* Description: This code checks for the existence of an HTML element with the id "elem" and makes an XMLHttpRequest to an API or endpoint.
* It handles both successful responses and errors by providing comments and suggestions.
*/
// Check if the element with id "elem" exists in the page
if (document.getElementById("elem")) {
@knolaust
knolaust / functions-disable-imgs.php
Last active January 30, 2024 15:01
How to Disable Unwanted Image Sizes From WordPress 5.3+
<?php
/**
* Disable Unnecessary Generated Image Sizes
* Author: Knol Aust
* Gist Keywords: wordpress, media library, images, image sizes
* Description: WordPress automatically generates multiple image sizes upon upload. This code disables unnecessary standard image sizes to reduce server/CDN bloat. Regenerate images after implementing.
*/
/**
* Disable generated image sizes.