Skip to content

Instantly share code, notes, and snippets.


Tonya Mork hellofromtonya

View GitHub Profile
hellofromtonya / test-trac53770.php
Last active Jul 28, 2021
Test script for rendering a table for the 'site_logo' & theme mod 'custom_logo' options
View test-trac53770.php
// Add this test script to wp-content/mu-plugins/test-trac53770.php
// Add the function into the theme where the site logo is rendered.
function test_trac53770_logo() {
$theme = get_option( 'stylesheet' );
$mods = get_theme_mods();
$options = array(
'get theme mods' => array(
hellofromtonya / t53165.php
Created Jul 19, 2021
Trac ticket 53165 - Test Custom Taxonomy added as a must-use plugin
View t53165.php
// Location of this code: wp-content/mu-plugins/t53165.php.
namespace Test\t53165;
add_action( 'init', __NAMESPACE__ . '\register_test_taxonomy' );
function register_test_taxonomy() {
$labels = array(
'name' => 'Tests',
'singular_name' => 'Test',
hellofromtonya / 28020.php
Created Apr 29, 2021
Testing script for WordPress Trac ticket 28020
View 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 / 51423.php
Created Mar 23, 2021
Core Ticket 51423: test script to make `wp_json_encode` fail during generation of personal data export JSON file.
View 51423.php
namespace Testing\Ticket51423;
add_action( 'wp_privacy_personal_data_export_file', __NAMESPACE__ . '\setup_testing_export_file', 5 );
function setup_testing_export_file( $request_id ) {
$GLOBALS['testing_51423'] = array(
'request_id' => $request_id,
'_export_data_grouped' => get_post_meta( $request_id, '_export_data_grouped', true ),
hellofromtonya / sample.html
Created Nov 25, 2020
Sample HTML for benchmarking
View sample.html
<!DOCTYPE html>
<html lang="en-US" class="js svg background-fixed">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="">
<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>
<title>Blog - Testing page</title>
<link rel="dns-prefetch" href="//">
<link href="" crossorigin="" rel="preconnect">
hellofromtonya / 50787.php
Last active Oct 15, 2020
Ticket 50787 WordPress Core
View 50787.php
* Return compatibility strings.
* @since 5.6.0
* @param string $key The key for the particular string.
* Default is false.
* @param string $name Plugin or theme name.
* @return string The appropriate compatibilty string.
hellofromtonya / mu_autoloader.php
Created Aug 16, 2020
Making Debug Toolkit plugin a must-use.
View mu_autoloader.php
require_once __DIR__ . '/debug-toolkit/debug-toolkit.php';
hellofromtonya /
Created Jun 8, 2019
Algorithm to get the longest sequential (consecutive set of numbers from the given unsorted list.
def longest_consecutive_subsequence(input_list):
Gets the longest sequential (consecutive set of numbers from the given unsorted list.
Time complexity is O(n) and space complexity is O(n).
This design uses Python's `range()` function to generate the list of sequential numbers. To accomplish this,
we iterate through the input list to find the least starting number and the number of sequential numbers.
It works on all integers.
hellofromtonya /
Last active Jun 7, 2019
Finding the Height and Diameter in a Binary Search Tree

Finding the Diameter of a Binary Tree

What is the diameter?

The diameter of a binary tree (sometimes called the width) is the number of nodes on the longest path between two leaves in the binary tree.

Edge Cases

The diameter can occur through:

hellofromtonya / books.php
Last active Mar 19, 2019
Show Custom Taxonomy Panel in the Gutenberg Editor
View books.php
* Adds Books to your website.
* @package KnowTheCode\Books
* @author hellofromTonya
* @license GPL-2.0+
* @wordpress-plugin
* Plugin Name: Books