Skip to content

Instantly share code, notes, and snippets.

View aristath's full-sized avatar
🏠

Ari Stathopoulos aristath

🏠
View GitHub Profile
  • WP_Hooks()->resort_active_iterations() - add documentation
  • WP_Hooks()->remove_filter() - Maybe the $exists var can be removed?
  • WP_Hooks()->remove_all_filters() - Maybe remove the isset() check?
  • WP_Hooks()->apply_filters() - Remove the array_splice condition.
  • WP_Hooks - Change is_null() to null ===

Maybe add a check to prevent the use of is_null() and recommend null ===? - EDIT: These are now opcode-cached in PHP7+, so it doesn't make a lot of sense to refactor them

Check the conditions in get_user_locale(). Something doesn't feel right.

<?php
add_filter(
'render_block',
function( $html ) {
static $styled_els = array();
$styles_to_add = '';
// Find elements that have inline styles.
preg_match_all( '/<[a-zA-Z0-9]+.+style=.+>/U', $html, $matches );
<?php
/**
* Runs on shutdown.
* This prevents any performance issues since it runs _after_ the page
* has finished loading and has already been served.
*/
add_action( 'shutdown', function() {
// Bail if not a singular entity.

PHP

  • Advocate for bumping the minimum PHP version: recent PHP versions are faster & lighter, so less CPU cycles and less energy consumption
  • PHP: Write more efficient code (for example use caches instead of repetative nested loops)

JS

  • Advocate for vanilla JS vs jQuery: Faster client-side and fewer assets to download
  • Advocate for service-workers in core
  • Find a way to remove the emojis script, or at least only load it when needed. It's 14kb on each page-load on 40% of the web, it's insane!

CSS

#include "CurieIMU.h"
#include <Adafruit_DotStar.h>
#include <SPI.h>
#define NUMPIXELS 60 // Number of LEDs in strip
#define MINBRIGHTNESS 100
#define MAXBRIGHTNESS 255
#define DATAPIN 5
#define CLOCKPIN 4
@aristath
aristath / sustainable-json-ld.html
Last active August 28, 2023 07:24
Research generating HTML from JSON-LD. Avoids content duplication, reducing the overall data transferred to clients. We only transfer the JSON-LD object, and then add a script to generate the HTML from it. The JS can be enqueued as an external asset so it gets cached browser-side. This is just a proof of concept.
<!-- Add a wrapper div. The content we generate from JSON-LD will be rendered here.-->
<div id="content-wrapper" style="max-width:70ch;margin-left:auto;margin-right:auto;"></div>
<!-- The JSON-LD of our recipe. -->
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Recipe",
"mainEntityOfPage": "https://www.allrecipes.com/recipe/12682/apple-pie-by-grandma-ople/",
"name": "Apple Pie by Grandma Ople",
<?php
/**
* Download gravatars locally.
*
* @package wptt/font-loader
* @license https://opensource.org/licenses/MIT
*/
namespace Aristath\LocalGravatars;
<?php // phpcs:ignore WordPress.Files.FileName
/**
*
* Add blocks styles inline.
*
* @package WPTRT/BlockAssets
*/
namespace WPTRT;
@aristath
aristath / phpcs.bash
Last active September 19, 2019 08:20 — forked from ilicfilip/tf-checkout.bash
Runs PHPCS on changed files only
if [ $# -lt 0 ]; then
echo "------------------------"
echo "usage: $0 \$1"
echo " \$1: Files to check"
echo "------------------------"
exit 1
fi
if [ "$#" == 1 ]
then
@aristath
aristath / poop.js
Last active September 10, 2019 21:31
jQuery replacement for WordPress themes. Contains the most widely-used functions.
/**
* Find an element.
*
* @param {string|Object} selector - The css selector of the element.
* If object then it can either be document or an element.
* @param {Object} parent - The parent element, or undefined for document.
* @return {Object} - returns the _lm object to allow chaining methods.
*/
var _lm = function( selector, parent ) {
parent = parent || document;