Skip to content

Instantly share code, notes, and snippets.

View davidwebca's full-sized avatar

David Lapointe Gilbert davidwebca

View GitHub Profile
@davidwebca
davidwebca / custom-wp-nav-menu-classes.php
Last active February 11, 2024 01:35
Allow adding custom classes to WordPress menu ul, li, a and at different depths. Perfect for TailwindCSS and AlpineJS usage.
<?php
/**
* WordPress filters to allow custom arguments to wp_nav_menu to,
* in turn, allow custom classes to every element of a menu.
*
* You can apply a class only to certain depth of your menu as well.
*
* The filters use the depth argument given by WordPress
* which is an index, thus starts with level 0 (zero).
*
@davidwebca
davidwebca / svg-functions.php
Last active January 26, 2021 19:50 — forked from kingkool68/svg-functions.php
SVG helper functions for WordPress
<?php
/**
* Include inline svg with + allow custom attributes as php function arguments
*
* Based on
* https://gist.github.com/kingkool68/6d72977fe8c82eeb9a85295ac3623cde#file-svg-functions-php
*
*/
/**
@davidwebca
davidwebca / gist:e26186b8f4c6795b19c043fffb6f9861
Last active December 18, 2023 15:29
Detect black screen and split with ffmpeg remux
# Splits video to separate scenes files when full black frames are found in the video
# Inspired by https://gist.github.com/achesco/4dc2ebf13378a0a61fc26c7fe01f539e
# Who got inspired by https://stackoverflow.com/a/38205105
#!/bin/bash
file=""
out="./"
dur=0.05
stripaudio=""
@davidwebca
davidwebca / override-wp-core-blocks-sage-10.php
Last active March 6, 2023 20:40
Add blade / override core block views in Sage 10.
<?php
/**
* Add this to your filters.php file in a Sage 10 theme.
* It will look at "resources/views/core/{blockname}.blade.php
* and render the view with "block_content" and "block" as variables.
*
* You can also use View Composers built in Sage 10 to pass more
* data to the block as you wish. For ACF blocks, I recommend
* generoi/sage-acfblocks which is definitely the cleanest
* method to include ACF blocks in Sage 10 I found so far.
@davidwebca
davidwebca / wp-global-post-count.php
Last active April 24, 2022 16:13
Global current_post counter, WP_Query agnostic
<?php
/**
* Create a globally accessible counter for all queries
* Even custom new WP_Query! Include inside functions.php in your theme.
* This allows you to have a post counter available in your sub-templates
* accessible even if you use get_template_part();
*
* Example
*
* global $current_loop_post_index;