Skip to content

Instantly share code, notes, and snippets.

View drdogbot7's full-sized avatar
🏚️
Working from home

Jeremy Mullis drdogbot7

🏚️
Working from home
  • Lawrence, KS
View GitHub Profile
@drdogbot7
drdogbot7 / editor.js
Last active August 3, 2022 14:36
Adding classes to wordpress paragraph, list and heading blocks
/**
* Add class names to core blocks that normally don't have them
*
* This does work, but any legacy p, ul, ol, h* will be invalid and will have to be recovered.
*/
const setExtraPropsToBlockType = (props, blockType, attributes) => {
const notDefined =
typeof props.className === 'undefined' || !props.className ? true : false;
@drdogbot7
drdogbot7 / LT-block-styles.php
Last active March 15, 2021 18:05
Register sidebar style for wordpress 'group' block.
<?php
/**
* @package LT_block_styles
* @version 0.1.0
*/
/*
Plugin Name: Lawrence Times Block Styles
Description: Register Custom Block styles for The Lawrence KS Times
Author: Jeremy Mullis
Version: 0.1.0
@drdogbot7
drdogbot7 / gist:ae995aaf4161868ffaec66835a0361d4
Last active November 4, 2022 05:01
EXIFTOOL command to tag resolution to 300 PPI (aka DPI)
There's no good reason to do this, but some automated file checks are set to reject files that aren't "300 DPI". You will need EXIFTOOL installed, obviously.
```shell
exiftool -XResolution=300 -YResolution=300 -overwrite_original my-stupid-file.jpg
# works on a buncha files too.
exiftool -XResolution=300 -YResolution=300 -overwrite_original ./*.jpg
```
@drdogbot7
drdogbot7 / carousel-fade.css
Created February 20, 2018 23:38
Bootstrap 4 carousel slide transition
@drdogbot7
drdogbot7 / docker-compose.yml
Last active February 18, 2023 23:50
Wordpress Docker Compose with CLI - official images
version: '2'
services:
db:
image: mysql:5.7
volumes:
- "./.data/db:/var/lib/mysql"
ports:
- "[YOUR_DESIRED_SQL_PORT]:3306"
environment:
MYSQL_ROOT_PASSWORD: wordpress
@drdogbot7
drdogbot7 / sticky-yet.js
Last active November 22, 2017 18:27
Are we sticky yet?
function areWeStickyYet( selector ) {
var stickyThing = document.querySelector( selector );
var CSSTop = parseInt( getComputedStyle( stickyThing, null ).getPropertyValue("top"), 10);
window.addEventListener( 'scroll', function() {
if ( stickyThing.getBoundingClientRect().top <= CSSTop ) {
stickyThing.classList.add('is_sticky');
return
}
stickyThing.classList.remove('is_sticky');
});
@drdogbot7
drdogbot7 / gist:2f97f933a3dc10d059b2a08a6dad786d
Created October 19, 2017 23:21
Wordpress Carbon Fields, Display Field on Home (Static)
add_action( 'carbon_fields_register_fields', 'crb_attach_home_options');
function crb_attach_home_options() {
Container::make( 'post_meta', 'Home' )
->where( 'post_id', '=', get_option( 'page_on_front' ) )
->add_fields( array(
Field::make( 'text', 'a_text_field' ),
));
}
@drdogbot7
drdogbot7 / breadcrumbs-navxt-twitter-bootstrap-v4-filter.md
Last active November 11, 2018 15:23
Breadcrumbs NavXT Twitter Bootstrap v4 filter

Bootstrap 4 requires classes to be placed on the individual <li>'s in order for the breadcrumb styles to work. I guess this is a good thing, but it makes it harder to use Breadcrumb NavXT.

This filter will add the appropriate classes. It also adds the "active" class to the current item.

Add to functions.php

<?php
function bootstrap_bcn_li_attributes( $li_class ) { 
@drdogbot7
drdogbot7 / sort-wordpress-categories-by-custom-field.md
Created November 3, 2016 20:30
Sort Wordpress categories by custom field

#Sort Wordpress categories by custom field:

where category_order is a custom field.

$categories = get_categories( $args );  

usort($categories, function($a, $b) {
   return get_field("category_order", "category_".$a->term_id) - get_field("category_order", "category_".$b->term_id);
});