Skip to content

Instantly share code, notes, and snippets.

Avatar

thisbit thisbit

View GitHub Profile
View webp-fallback.css
/* Old Browsers Use this - read Safari */
element.classname {
background: url("../images/image.jpg");
}
/* Chrome 66+, Edge 79+, Opera 53+, Android Brower 80+ */
@media screen and (-webkit-min-device-pixel-ratio: 0) and (min-resolution:.001dpcm) {
@supports (background-image: -webkit-image-set(url("../images/repozitorij.webp") 1x)) {
element.classname {
background: url("../images/image.jpg");
View gb-query-block-filter.php
<?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 / theme.json
Created Jul 14, 2022
The Best Theme Json on the Internet
View theme.json
{
"version": 2,
"settings": {
"typography": {
"letterSpacing": false,
"Appearance": false,
"letterCase": false,
"fontFamily": false,
"fontSize": false,
"fontStyle": false,
@thisbit
thisbit / fallback_featured_image.php
Last active Jul 5, 2022
Fallback image whenever there is not featured image
View fallback_featured_image.php
View classic_plaintext_and_gutenberg.php
<?php
/**
* This file provides differnt levels of formating ability per post type
* Posts are in plain classic editor
* Osoblje CPT have no formating controls, pure plain text
* The rest is more or less in gutenberg
* I may later add gutenberg for admins in posts ... perhaps
*/
@thisbit
thisbit / remove-empty-p.php
Created Jun 1, 2022 — forked from ninnypants/remove-empty-p.php
Remove empty p tags from WordPress posts
View remove-empty-p.php
<?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 — forked from yankiara/scroll-direction.js
Scroll direction for sticky header/footer, etc.
View scroll-direction.js
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 / sticky-nav.css
Last active Jun 23, 2022
Custom Sticky bar instead of GeneratePress jQuery solution
View sticky-nav.css
/**
* Enqueue this file like the above or use WPCodeBox snippets plugin to do it, or add it to customizer custom CSS box
*/
/* custom sticky header */
.main-navigation {
transition: all ease .5s;
position: fixed;
top: 0;
left:0;
View thisbit-filtering-assets.css
/* essential hiding utility */
.is-hidden {
display: none !important;
}
/**
Design, could be also moved to theme
*/
View thisbit-filtering-query.php
<?php
/**
* Shortcode for generating filters to filter output of GenerateBlocks query loop
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}