Skip to content

Instantly share code, notes, and snippets.

View hellofromtonya's full-sized avatar

Tonya Mork hellofromtonya

View GitHub Profile
@hellofromtonya
hellofromtonya / term-hierarchical-search.php
Last active February 27, 2024 13:18
WordPress Term Hierarchical Search
<?php
/**
* Term Hierarchical Search
*
* These methods provide a utility interface to find a meta value
* within the term's hierarchy. It walks up the hierarchy starting
* at the given term, i.e. walks to its parent -> grandparent -> N levels.
*
* It's performant as it grabs the records it needs out of the database
* with one SQL query, i.e. to avoid multiple trips to gather each level's
@hellofromtonya
hellofromtonya / README.md
Last active February 15, 2023 19:18
Web Fonts Tester plugin: uses Jetpack's Google Fonts composer package.

Web Fonts API tester plugin using Jetpack's Google Fonts composer package

This is a tester plugin for the Web Fonts API. It uses the Jetpack Google Fonts Provider composer package.

This package uses the original webfonts array structure, which is now deprecated.

How to install

  1. In your local dev environment, create a new folder in wp-content/plugins/ called webfonts.
  2. In a command line tool (such as Terminal), type: composer install.
@hellofromtonya
hellofromtonya / .gitignore_global
Created February 24, 2018 21:48
Global gitignore
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@hellofromtonya
hellofromtonya / changes.md
Created December 13, 2022 13:41
Web Fonts API architectural changes

Web Fonts API architectural changes

Web fonts array passed to wp_register_webfonts() changed:

Original API: each variation identifies its font-family.

wp_register_webfonts(
     array(
         array(
             'provider'    => 'local',
@hellofromtonya
hellofromtonya / mu-test.php
Created October 31, 2022 20:57
Must-use test file for Trac 56933.
<?php
add_action( 'loop_start', 'test_56933', 12 );
// For testing https://core.trac.wordpress.org/ticket/56933.
function test_56933() {
global $wpdb;
$search_string = 'hello';
$sql = $wpdb->prepare("(select $wpdb->posts.ID, post_title, {$wpdb->prefix}mgmlp_folders.folder_id, pm.meta_value as attached_file, 'a' as item_type
@hellofromtonya
hellofromtonya / adjacent-parent-post.php
Created September 25, 2016 19:51
Limits the adjacent post to just parents (no children)
<?php
/**
* Get the next adjacent parent post.
*
* This function extends the SQL WHERE query of the WordPress get_adjacent_post()
* function. It registers a callback to the `get_next_post_where` event filter,
* which then adds a new WHERE parameter.
*
* @uses get_next_post()
@hellofromtonya
hellofromtonya / 28020.php
Created April 29, 2021 17:16
Testing script for WordPress Trac ticket 28020
<?php
namespace Test\trac28020;
/**
* Add this file into the wp-content/mu-plugins folder.
*/
add_action( 'init', function() {
// Bail out if in the backend (Admin area). Only want to run this in the frontend.
if ( is_admin() ) {
@hellofromtonya
hellofromtonya / testcpt.php
Created January 25, 2022 13:58
Basic CPT plugin
<?php
/**
* Test CPT with TT2.
*
* Plugin Name: Test CPT
* Plugin URI: https://github.com/tester/testcpt/
* Description: Tests custom post type blank screen with TT2
* Version: 1.0
* Author: tester
* Author URI: https://github.com/tester/testcpt/
@hellofromtonya
hellofromtonya / TEST_REPORT.md
Created November 5, 2021 21:46
Test Report experimentation with validating webfonts schema

Test Report

All tests are done the Validator commented out, i.e. no validation.

Testing Environment: *

  • Browser: Chrome
  • Theme: Twenty-Twenty Two (modified to use the Webfonts API)
  • Webfonts: Local and Google Fonts
@hellofromtonya
hellofromtonya / bio.md
Created October 11, 2021 14:56
Tonya's speaker bio

Tonya Mork is an engineering leader, engineer², strategist, and coach. Her story began in the mid-1980s with building high-tech automated manufacturing systems. Then life threw her a curve ball. She shifted her focus to helping developers and organizations excel. These days you'll find her focused on empowering people and tech to make the web better. Tonya is based in the US and is a full-time sponsored WordPress Core committer and open source contributor.