Skip to content

Instantly share code, notes, and snippets.

View hellofromtonya's full-sized avatar

Tonya Mork hellofromtonya

View GitHub Profile
@hellofromtonya
hellofromtonya / test-trac53770.php
Last active July 28, 2021 18:33
Test script for rendering a table for the 'site_logo' & theme mod 'custom_logo' options
<?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
hellofromtonya / t53165.php
Created July 19, 2021 14:58
Trac ticket 53165 - Test Custom Taxonomy added as a must-use plugin
<?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
hellofromtonya / 51423.php
Created March 23, 2021 17:32
Core Ticket 51423: test script to make `wp_json_encode` fail during generation of personal data export JSON file.
<?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
hellofromtonya / sample.html
Created November 25, 2020 18:46
Sample HTML for benchmarking
<!DOCTYPE html>
<html lang="en-US" class="js svg background-fixed">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<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="//fonts.googleapis.com">
<link href="https://fonts.gstatic.com" crossorigin="" rel="preconnect">
@hellofromtonya
hellofromtonya / functions.php
Last active November 16, 2020 19:42
Add After Entry Widget to All Post Types, including Custom Post Types
//* Make sure your child theme has this line in the functions.php file
add_theme_support('genesis-after-entry-widget-area');
add_action( 'genesis_after_entry', 'lunarwp_add_after_entry_widget_area' );
/**
* Display after-entry widget area on the genesis_after_entry action hook.
*
* @since 1.0.0
*
* @uses genesis_widget_area() Output widget area.
@hellofromtonya
hellofromtonya / 50787.php
Last active October 15, 2020 11:43
Ticket 50787 WordPress Core
/**
* 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
hellofromtonya / mu_autoloader.php
Created August 16, 2020 19:40
Making Debug Toolkit plugin a must-use.
<?php
require_once __DIR__ . '/debug-toolkit/debug-toolkit.php';
@hellofromtonya
hellofromtonya / variable-refcount.php
Created March 19, 2019 17:15
Exploring PHP Variables, recount, and copy on write.
<?php
add_action( 'init', function() {
/**
* 1. PHP adds the variable into the symbols table.
* 2. PHP adds the value into the data table, which is called zval.
* 3. PHP points the value location to the variable location, binding them together.
* 4. refcount is incremented to 1.
*/
@hellofromtonya
hellofromtonya / .gitconfig
Last active December 27, 2019 13:59
Git Productive - Global .gitconfig aliases
[alias]
# Opens the Atom editor.
atom = ! atom
# ===================================
# Viewing history
# ===================================
# Shows a graphical log.
logone = log --oneline --decorate --all --graph
@hellofromtonya
hellofromtonya / longest_consecutive_subsequence_algorithm.py
Created June 8, 2019 02:21
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.