Skip to content

Instantly share code, notes, and snippets.

View brianleejackson's full-sized avatar
✍️
Writing

Brian Jackson brianleejackson

✍️
Writing
View GitHub Profile
add_filter( 'wp_theme_json_data_theme', 'disable_inter_font', 100 );
function disable_inter_font( $theme_json ) {
$theme_data = $theme_json->get_data();
$font_data = $theme_data['settings']['typography']['fontFamilies']['theme'] ?? array();
// The font name to be removed
$font_name = 'Inter';
// Check if 'Inter' font exists
foreach ( $font_data as $font_key => $font ) {
if ( isset( $font['name'] ) && $font['name'] === $font_name ) {
// Remove the font
@brianleejackson
brianleejackson / wlwmanifest-link.php
Created May 24, 2024 04:27
Remove wlwmanifest link in WordPress
@brianleejackson
brianleejackson / disable-wordpress-fetch-priority.php
Created December 8, 2023 03:58
Disable WordPress core fetch priority
function disable_fetchpriority_high( $loading_attrs ) {
unset( $loading_attrs['fetchpriority'] );
return $loading_attrs;
}
add_filter(
'wp_get_loading_optimization_attributes',
'disable_fetchpriority_high'
);
@brianleejackson
brianleejackson / divi-cls-fix.js
Last active July 25, 2024 20:03
Fix Divi CLS (make sure to also exclude it from Delay JS).
<script type="text/javascript">
var elm=document.getElementsByTagName("html")[0];
elm.style.display="none";
document.addEventListener("DOMContentLoaded",function(event) {elm.style.display="block"; });
</script>
<?php
add_action( 'shutdown', function() {
// If the event is scheduled, don't run anything.
if ( wp_next_scheduled( 'prefix_remove_license_activation_logs' ) ) {
return;
}
if ( ! function_exists( 'edd_has_upgrade_completed' ) ) {
@brianleejackson
brianleejackson / fastclick-mobile-only.js
Created March 1, 2023 22:32
Only load FastClick on mobile devices (no tablets or desktop)
<script>
if (window.innerwidth < 900) {
document.write('<script type="text/javascript" src="https://domain.com/wp-content/plugins/perfmatters/vendor/fastclick/fastclick.min.js"><\/script>');
}
</script>
<script>
if(window.innerWidth < 900) {
if('addEventListener' in document) {
document.addEventListener('DOMContentLoaded', function() {
@brianleejackson
brianleejackson / content-visibility.css
Last active September 26, 2024 03:26
Add content-visibility to WordPress element (lazy render)
.nameofdiv {
content-visibility: auto;
contain-intrinsic-size: 0 1000px;
}
/* References:
https://web.dev/content-visibility/
https://segmentfault.com/a/1190000041980427/en
https://clubmate.fi/content-visibility-auto
https://dev.to/dailydevtips1/i-made-my-website-28ms-faster-with-content-visibility-466e
@brianleejackson
brianleejackson / obsidian-custom-css.css
Last active July 21, 2023 05:06
Obsidian custom CSS
/* preview-mode paragraphs */
p{
padding-top: 6px;
padding-bottom: 6px;
line-height: 1.6;
}
/* preview-mode lists */
li{
padding-top: 6px;
@brianleejackson
brianleejackson / line-breaks-fluent-forms.php
Created December 28, 2022 17:59
Remove additional line breaks in Fluent Forms WordPress plugin
add_filter('fluentform_response_render_textarea', function ($value, $field, $formId, $isHtml) {
if (false != strpos($value, '<br />')) {
$value = str_replace('<br />', '', $value);
}
return '<span style="white-space: pre-line">' . $value . '</span>';
}, 15, 4);
add_filter('perfmatters_delay_js_exclusions', function($exclusions) {
if(is_page(275)) {
$exclusions[] = 'underscore.min.js';
$exclusions[] = 'backbone.min.js';
$exclusions[] = 'front-end-deps.js';
$exclusions[] = 'front-end.js';
$exclusions[] = 'nf-';
$exclusions[] = 'jquery.min.js';
$exclusions[] = 'nfForms';
}