Skip to content

Instantly share code, notes, and snippets.

View aristath's full-sized avatar
🏠

Ari Stathopoulos aristath

🏠
View GitHub Profile
@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",
  • 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.
@aristath
aristath / custom-post-type-plugin.php
Last active July 21, 2021 13:08
sample theme to test REST
<?php
/**
* Plugin Name: Code Meta fields.
*
* @package My Theme
*/
/**
* Register the post-type.
*/

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

@aristath
aristath / migrate.md
Created April 17, 2014 09:27
Migrate from a stand-alone WordPress site to an easyengine server.

BASIC SETUP

Install ee:

curl -sL rt.cx/ee | sudo bash
ee system install

CHANGE CONFIGURATION

@aristath
aristath / aricolor.md
Last active December 18, 2020 10:48
ariColor PHP Library for WordPress plugins and themes

ariColor is a PHP library that will hopefully help WordPress theme developers do their job easier and more effectively.

It does not provide you with methods like lighten(), darken() etc. Instead, what it does is give you the ability to create these yourself with extreme ease by giving you all the properties of a color at hand, and allowing you to manipulate them however you see fit.

Example:

First, let's create our color object:

$color = ariColor::newColor( '#049CBE', 'hex' );
<?php
function idesign_customizer_config() {
$url = get_stylesheet_directory_uri() . '/inc/kirki/';
/**
* If you need to include Kirki in your theme,
* then you may want to consider adding the translations here
#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