Skip to content

Instantly share code, notes, and snippets.

Avatar
✍️
Writing

Brian Jackson brianleejackson

✍️
Writing
View GitHub Profile
@brianleejackson
brianleejackson / enqueue-preload-font.php
Created Sep 23, 2020
Enqueue and preload a font in WordPress
View enqueue-preload-font.php
function enqueue_font_preload() {
wp_enqueue_style('example-font-handle', 'https://domain.com/wp-content/font-file.woff2', array(), null);
}
add_action('wp_enqueue_scripts', 'enqueue_font_preload');
function style_loader_tag_filter_preload($html, $handle) {
if($handle === 'example-font-handle') {
$new_html = str_replace("text/css", "font/woff2", $html);
return str_replace("rel='stylesheet'", "rel='preload' as='font' crossorigin='anonymous'", $new_html);
}
return $html;
@brianleejackson
brianleejackson / disable-font-awesome-yith.php
Created Aug 28, 2020
Disable Font Awesome in YITH WooCommerce Wishlist
View disable-font-awesome-yith.php
if ( function_exists( 'yith_wishlist_install' ) ){
if ( ! function_exists( 'yith_wcwl_remove_awesome_stylesheet' ) ) {
function yith_wcwl_remove_awesome_stylesheet() {
wp_deregister_style( 'yith-wcwl-font-awesome' );
}
@brianleejackson
brianleejackson / back-next-generatepress.css
Last active Aug 21, 2020
Replace page numbers in GeneratePress with next and back. Seen here: https://woorkup.com/
View back-next-generatepress.css
.nav-links .page-numbers:not(.next):not(.prev) {
display: none;
}
@brianleejackson
brianleejackson / scroll-sticky-widget-no-jquery.css
Last active Aug 19, 2020
Scroll sticky sidebar WordPress widget with no jQuery
View scroll-sticky-widget-no-jquery.css
@media (min-width: 769px) {
.site-content {
display: flex;
}
.inside-right-sidebar {
height: 100%;
}
.inside-right-sidebar aside:last-child {
position: -webkit-sticky;
position: sticky;
@brianleejackson
brianleejackson / progress-bars-no-jquery.css
Last active Aug 18, 2020
Progress bars with no jQuery as seen here: https://pennybros.com/
View progress-bars-no-jquery.css
/*Progress bar CSS*/
.meter {
height: 30px;
position: relative;
background: #f3efe6;
border-radius:3px;
overflow: hidden;
margin: 5px 0 5px 0;
}
.meter span {
View rankmath-wp-coupons-schema-breadcrumb.php
//filter coupon post breadcrumbs
add_filter('rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
if(is_singular('coupon')){
//change archive page name
$crumbs[count($crumbs)-2][0] = "Lifetime Deals";
}
return $crumbs;
}, 10, 2);
@brianleejackson
brianleejackson / exclude-logo-lazy-load-generatepress.php
Last active Jun 26, 2020
Exclude logo (desktop and mobile) from lazy load in GeneratePress theme with Perfmatters plugin. Source: https://perfmatters.io/docs/lazy-load-wordpress/
View exclude-logo-lazy-load-generatepress.php
//add no-lazy class to primary logo
function wpd_generate_logo_output($output, $logo_url, $html_attr) {
//add our no-lazy class
$html_attr = str_replace('class="', 'class="no-lazy ', $html_attr);
//logo output
printf(
'<div class="site-logo no-lazy">
<a href="%1$s" title="%2$s" rel="home">
@brianleejackson
brianleejackson / generatepress-author-sidebar-widget.html
Last active Jun 12, 2020
GeneratePress author sidebar widget box as seen here: https://woorkup.com/
View generatepress-author-sidebar-widget.html
<center><img src="https://domain.com/bio-pic.png" class="no-lazy" width="175" height="175" alt=""></center>
<div style="background:#FAF3D4; color: #5d5b54; margin: 15px 0; padding: 1em 1em; border-width: 0 0 0 12px;"><strong style="font-size:19px;">Hi there, I'm {name}. <a href="https://twitter.com/username" target="_blank" style="border-bottom:0px; color:#504e48;" rel="noopener noreferrer"><i class="fa fa-twitter fa-2x;" aria-hidden="true"></i></a></strong><br
/><span style="line-height:23px;font-size:18px;">Write something about you. <strong><a style="color:#504e48; border-bottom: 2px solid rgba(80, 78, 72, 0.2);" href="https://domain.com/about/">Read more</a></strong></span></div>
@brianleejackson
brianleejackson / woorkup.css
Last active Sep 2, 2020
woorkup custom CSS used with GeneratePress theme. Source: https://woorkup.com/generatepress-review/
View woorkup.css
/*fonts*/
.entry-title a {
color: #333333;
}
.nav-links .page-numbers:not(.next):not(.prev) {
display: none;
}
strong {color:#202020;}
.no-border a, .no-border a:visited {
color: #4c5357;
@brianleejackson
brianleejackson / remove-slug-cpt-alternate.php
Last active May 29, 2020
Alternative way to remove the base slug from custom post type URL. Source: https://woorkup.com/wordpress-custom-post-type/
View remove-slug-cpt-alternate.php
function bis_remove_cpt_slug($args, $post_type) {
if(in_array($post_type, array('artist'))) {
$args['rewrite'] = array('slug' => '/');
}
return $args;
}
add_filter('register_post_type_args', 'bis_remove_cpt_slug', 10, 2);
You can’t perform that action at this time.