Skip to content

Instantly share code, notes, and snippets.

View audrasjb's full-sized avatar

Jb Audras audrasjb

View GitHub Profile
@audrasjb
audrasjb / who-yoast-reading-time-shortcode.php
Created February 27, 2025 14:17
Adds Yoast reading time post meta in a shortcode: [yoast-reading-time]
<?php
/**
* Plugin Name: Yoast Reading Time Shortcode
* Description: Adds Yoast reading time post meta in a shortcode.
* Author: Jb Audras @ Whodunit
* Version: 0.1
* Author URI: https://whodunit.fr
*/
/**
@audrasjb
audrasjb / blueprint-force-youtube-nocookie.json
Created January 29, 2025 13:27
WP Playground blueprint for running the Who Force No-cookies Youtube Embed plugin
{
"landingPage": "/",
"login": true,
"plugins": [
"https://jeanbaptisteaudras.com/playground/who-youtube-embed-nocookie.zip"
],
"siteOptions": {
"blogname": "Youtube without cookies"
}
}
@audrasjb
audrasjb / who-youtube-embed-nocookie.php
Created January 29, 2025 13:19
Force no-cookie domain for Youtube embeds
<?php
/*
Plugin Name: Force no-cookie domain for Youtube embeds.
Plugin URI: https://whodunit.fr
Description: Forces no-cookie domain on every Youtube embed.
Author: Whodunit
Version: 1.0
Author URI: https://whodunit.fr
*/
@audrasjb
audrasjb / testing-white-admin-scheme.json
Last active January 20, 2025 23:13
WP Playground Test White Background Admin Scheme
{
"landingPage": "/wp-admin/",
"login": true,
"plugins": [
"https://jeanbaptisteaudras.com/playground/2025-core-admin-colors.zip"
],
"siteOptions": {
"blogname": "White Admin Scheme"
}
}
@audrasjb
audrasjb / playground-blueprint-yoast-reading-time.json
Last active January 20, 2025 20:31
Playground snippet to run Yoast reading time custom function
{
"$schema": "https://playground.wordpress.net/blueprint-schema.json",
"meta": {
"title": "Yoast reading time post meta",
"description": "Add Yoast reading time post meta before posts content",
"author": "audrasjb",
},
"steps": [
{
"step": "installPlugin",
@audrasjb
audrasjb / jba-yoast-reading-time.php
Last active January 20, 2025 11:31
Add Yoast reading time post meta before posts content
<?php
/**
* Plugin Name: Add Yoast reading time post meta before posts content.
* Author: Jb Audras
* Version: 0.1
* Author URI: https://whodunit.fr
*/
/**
* Gets Yoast reading time and add it before the content.
@audrasjb
audrasjb / jba-remove-default-theme-patterns.php
Last active January 16, 2025 18:12
Remove default theme patterns
<?php
/**
* Plugin Name: Remove default theme patterns.
* Author: Jb Audras
* Version: 0.1
* Author URI: https://whodunit.fr
*/
/**
* Unregisters default patterns from TT5.
@audrasjb
audrasjb / wp-playground-opquast-widget
Last active January 16, 2025 09:00
WordPress Playground instance for Opquast widget
{
"landingPage": "/wp-admin/",
"login": true,
"plugins": [
"https://jeanbaptisteaudras.com/plugins/who-opquast-widgets.zip"
],
"siteOptions": {
"blogname": "Le joli widget Opquast"
}
}
@audrasjb
audrasjb / accessible-external-links.php
Last active January 14, 2025 08:14
Filters blocks to automatically add aria-label to links that open in a new tab.
/**
* Filters the_content to automatically add unique ID to headings.
*
* Note: Change the regex to modify the related heading levels.
* Defaults to levels 2 and 3.
*/
function who_automatic_heading_ids( $content ) {
$pattern = "~<h(2|3)[^>]*>(.*?)</h(2|3)>~";
$content = preg_replace_callback( $pattern, function ( $matches ) {
$title = $matches[2];