Skip to content

Instantly share code, notes, and snippets.

View dkjensen's full-sized avatar
🏠
Working from home

David Jensen dkjensen

🏠
Working from home
View GitHub Profile
@dkjensen
dkjensen / blog-post.php
Created February 7, 2024 21:06
Sample WP Block Template Part
<?php
/**
* Template Part: Blog
*
* @package CloudCatch\Sample
*/
use function CloudCatch\Sample\get_post_icon;
$sample_blog_categories = wp_get_post_terms( get_the_ID(), 'category', array( 'fields' => 'names' ) );
@dkjensen
dkjensen / README.md
Last active March 4, 2024 22:35
WordPress Query Block as Splide Carousel

Instructions

  1. Add your query block, and give it a class of is-style-carousel.
  2. Add the code from block-editor.php somewhere such as your child theme functions.php file.
  3. Configure Splide options in the query_carousel_block_init() function.
@dkjensen
dkjensen / .lando.yml
Created October 30, 2023 19:48
Lando + XDebug + VSCode + WordPress
name: sandbox.local
recipe: wordpress
config:
php: 8.2
webroot: www
services:
database:
type: mariadb
appserver:
xdebug: true
@dkjensen
dkjensen / windows-wsl2-docker-lando-php-xdebug.md
Created June 18, 2023 18:34 — forked from rockschtar/windows-wsl2-docker-lando-php-xdebug.md
Windows 10/11 + WSL2 + Docker + Lando + PHP XDebug (PHPStorm, IntelliJ & Visual Studio Code (vscode))
  1. Install WSL
  2. Install your preferred WSL Linux Distro vom Microsoft Store. In my case I used Ubuntu 20.04.
  3. Install Docker for Windows
  4. Enable Docker WSL2 Integration image
  5. Install Lando inside WSL
wget https://github.com/lando/lando/releases/download/v3.6.0/lando-x64-v3.6.0.deb
dpkg -i --ignore-depends=docker-ce lando-x64-v3.6.0.deb
@dkjensen
dkjensen / filters.php
Last active April 3, 2024 21:05
WordPress Gutenberg Query Loop View More AJAX
<?php
/**
* Add data attributes to the query block to describe the block query.
*
* @param string $block_content Default query content.
* @param array $block Parsed block.
* @return string
*/
function query_render_block( $block_content, $block ) {
global $wp_query;
@dkjensen
dkjensen / osa-wave-r1.js
Created October 13, 2021 05:57
OSA Wave
"use strict";
var waves = document.querySelectorAll('[data-wave]');
var devicePixelRatio = window.devicePixelRatio || 1;
waves.forEach(function (wave) {
var fillColor = wave.getAttribute('data-fill') || '#f0f';
var clipDirection = wave.getAttribute('data-clip-direction') || 'top';
var containerWrapper = document.createElement('div');
containerWrapper.classList = 'containerWrapper';
var container = document.createElement('div');
@dkjensen
dkjensen / cart-table.php
Created July 21, 2020 22:28
Display SKU on WC Cart PDF table
<?php
/**
* WC Cart PDF template
*
* @package wc-cart-pdf
*/
/**
* Before template hook
*
@dkjensen
dkjensen / gist:40720f200dfc60136569c1d38fb4bb51
Last active February 16, 2017 08:54
WordPress - Display logged in users name in menu
/**
* Change the first item text in a WP menu to the users display name
*
* @param string $title The menu item's title.
* @param WP_Post $item The current menu item.
* @param stdClass $args An object of wp_nav_menu() arguments.
* @param int $depth Depth of menu item. Used for padding.
*/
function wp_nav_menu_display_name( $title, $item, $args, $depth ) {
if( is_user_logged_in() ) {