Skip to content

Instantly share code, notes, and snippets.

View sethrubenstein's full-sized avatar
🦃

Seth Rubenstein sethrubenstein

🦃
View GitHub Profile
@sethrubenstein
sethrubenstein / AGENTS.md
Last active October 11, 2025 14:07
GitHub Copilot WordPress

AGENTS.md

This file provides guidance to AI agents when working with code in this repository.

PRC Platform Architecture

This is a WordPress VIP platform for Pew Research Center's digital publishing. It's built as a monorepo with:

  • WordPress multisite structure with subdirectory setup
  • Monorepo architecture using npm workspaces
@sethrubenstein
sethrubenstein / class-core-dialog.php
Last active September 12, 2025 15:09
core/dialog extensibility
<?php
/**
* Core Dialog Block
*
* @package PRC\Platform\Blocks
*/
namespace PRC\Platform\Blocks;
use WP_HTML_Tag_Processor;
@sethrubenstein
sethrubenstein / README.md
Created November 6, 2024 17:23
Gutenberg Post Publish Pipeline

Post Publish Pipeline

Client Side Hooks

All client side hooks received {edits, postId, postStatus, postType} properties:

  • prc-platform.onSiteEdit Occurs every time an update is saved in the site editor.
  • prc-platform.onPostInit Occurs once, when a post transition from non existent to draft state.
  • prc-platform.onIncrementalSave Occurs often, whenever a post in a draft state is updated.
  • prc-platform.onPublish Occurs when a post transitions from draft to publish state.
<?php
/**
* WP_HTML_Table_Processor
* @author Seth Rubenstein
*/
/**
* Pass in a table and get back an array of the header, rows, and footer cells quickly and effeciently.
*
* The WP_HTML_Tag_Processor bookmark tree navigation is heavily cribbed from WP_Directive_Processor class https://github.com/WordPress/block-interactivity-experiments/pull/169/files#diff-ad36045951e27010af027ae380350ae4b07b56a659a3127b40b7967b2308d5bc
@sethrubenstein
sethrubenstein / get-color-values-from-theme-json.php
Created March 26, 2023 15:53
Provides an example of how to extract your color palette from a theme.json file and create styles dynamically.
<?php
function generate_css_from_theme_settings() {
if ( !function_exists('wp_get_global_settings') ) {
return new WP_Error('missing_function', 'wp_get_global_settings() is missing');
}
$colors = wp_get_global_settings();
$colors = $colors['color']['palette']['theme'];
q1_by_sex = svyby(~q1, #variable to estimate
~sex, #subgroup variable
design = Apr17_design,
FUN = svymean, #function to use on each subgroup
keep.names = FALSE #does not include row.names
#for subgroup variable
)
knitr::kable(q1_by_sex, digits = 2)
@sethrubenstein
sethrubenstein / cf-invalidate.php
Created August 15, 2017 20:11 — forked from claylo/cf-invalidate.php
How to invalidate items in AWS CloudFront
<?php
/**
* Super-simple AWS CloudFront Invalidation Script
*
* Steps:
* 1. Set your AWS access_key
* 2. Set your AWS secret_key
* 3. Set your CloudFront Distribution ID
* 4. Define the batch of paths to invalidate
* 5. Run it on the command-line with: php cf-invalidate.php
@sethrubenstein
sethrubenstein / Customfile
Created January 4, 2017 18:03 — forked from lkwdwrd/Customfile
VVV Customfile for Hyper-V compatibility
# Hyper-V only overrides
config.vm.provider :hyperv do |v, override|
# Update memory and CPUs to match VVV config.
v.memory = 1024
v.cpus = 1
# Use a Hyper-V compatible base box
override.vm.box = "ericmann/trusty64
# Change all the folder to use SMB instead of Virtual Box shares
/**
* Get or update post meta via the WordPress REST API
*
* @param int $post_id Post ID to get meta for.
* @param bool|string $json_url Optional. Base URL for API. If false will use current site's API URL.
* @param array $headers Headers to use in request. Must at least include authorization.
* @param bool $update Optional. If true updates meta value, if false just returns current values.
* @param bool|array $meta_data Optional, but required if updating. Array of key => value for meta ID being updated.
* @param bool|int $meta_id Optional. ID of meta key to update. If not specified and updating an additional HTTP request is required to find it.
*
@sethrubenstein
sethrubenstein / prepare-commit-msg.sh
Created March 28, 2016 19:49 — forked from bartoszmajsak/prepare-commit-msg.sh
How to automatically prepend git commit with a branch name
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"