Skip to content

Instantly share code, notes, and snippets.

View thisbit's full-sized avatar

thisbit thisbit

View GitHub Profile
<?php
// GenerateBlocks variant of pre_get_posts for the query block
add_filter( 'generateblocks_query_loop_args', function( $query_args, $attributes ) {
if ( ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'custom-grid-class' ) !== false ) {
$query_args['meta_key'] = 'field_name';
$query_args['orderby'] = 'meta_value'; // better for strings
// $query_args['orderby'] = 'meta_value_num'; // better for numbers
$query_args['order'] = 'ASC';
@thisbit
thisbit / remove-empty-p.php
Created June 1, 2022 21:55 — forked from ninnypants/remove-empty-p.php
Remove empty p tags from WordPress posts
<?php
add_filter( 'the_content', 'remove_empty_p', 20, 1 );
function remove_empty_p( $content ){
// clean up p tags around block elements
$content = preg_replace( array(
'#<p>\s*<(div|aside|section|article|header|footer)#',
'#</(div|aside|section|article|header|footer)>\s*</p>#',
'#</(div|aside|section|article|header|footer)>\s*<br ?/?>#',
'#<(div|aside|section|article|header|footer)(.*?)>\s*</p>#',
'#<p>\s*</(div|aside|section|article|header|footer)#',
@thisbit
thisbit / scroll-direction.js
Created May 27, 2022 09:32 — forked from yankiara/scroll-direction.js
Scroll direction for sticky header/footer, etc.
window.addEventListener( 'DOMContentLoaded', ()=> {
const body = document.body,
scrollUp = "scroll-up",
scrollDown = "scroll-down",
offset = 0;
let lastScroll = window.pageYOffset;
if ( lastScroll > offset ) {
body.classList.add(scrollUp);
@thisbit
thisbit / functions.php
Created May 4, 2022 15:36 — forked from jmccall75/functions.php
Locking down Gutenberg...
<?php
/**
* Gutenberg Block customization for this theme.
*/
// gutenberg disable for posts
//add_filter('use_block_editor_for_post', '__return_false', 10);
// gutenberg disable for post types
//add_filter('use_block_editor_for_post_type', '__return_false', 10);
@thisbit
thisbit / github_desktop_ubuntu.sh
Created April 30, 2022 12:21 — forked from berkorbay/github_desktop_ubuntu.md
To install Github Desktop for Ubuntu
## Follow this link for further updates to Github Desktop for Ubuntu https://github.com/shiftkey/desktop/releases/latest
# UPDATE (2021-10-18): Thanks to Amin Yahyaabadi's message, the updated code is as follows
sudo wget https://github.com/shiftkey/desktop/releases/download/release-2.9.3-linux3/GitHubDesktop-linux-2.9.3-linux3.deb
### Uncomment below line if you have not installed gdebi-core before
# sudo apt-get install gdebi-core
sudo gdebi GitHubDesktop-linux-2.9.3-linux3.deb
# UPDATE (2021-03-05): Thanks to PaoloRanzi81's comment, the updated code is as follows https://gist.github.com/PaoloRanzi81
@thisbit
thisbit / hd-just-in-time-css.php
Created January 12, 2022 13:42 — forked from wpmark/hd-just-in-time-css.php
A plugin to provide Just in Time CSS for WordPress blocks
<?php
/*
Plugin Name: Just in Time CSS
Plugin URI: https://highrise.digital/
Description: A plugin from Highrise Digital to provide just in time CSS functionality.
Version: 1.0
License: GPL-2.0+
Author: Highrise Digital Ltd
Author URI: https://highrise.digital/
Text domain: hd-just-in-time-css