Skip to content

Instantly share code, notes, and snippets.

@brandonjp
brandonjp / findOverflowParents.js
Last active April 8, 2026 14:47
find overflow:hidden ancestors
// when you're trying to use `position:sticky` on an element
// you'll have trouble if any parent/ancestor element has
// overflow set to anything other than "visible" (such as: auto,hidden,overlay,scroll)
// & turns out if a parent is `display:flex` it might need some love
// (to remedy this you can set the `align-self` of your sticky element)
// see here for how the display & align-self properties affect: http://bit.ly/2ZaRu4o
// so, to find those troublesome parents...
// copy & paste this into Chrome Inspector/Dev Tools console
// (and be sure to change the #stickyElement below, if needed)
@brandonjp
brandonjp / wp-edit_published_posts-fix.php
Last active January 31, 2026 14:26
Allow non-Author to edit & save a published wordpress post. This works around issues with `_wp_translate_postdata` & `user_has_cap` - Fixes "Sorry, you are not allowed to edit posts as this user."
<?php
/*
*
* ALLOW USER TO EDIT POST IF THEY ARE SELECTED AS THE PM
* Preferred way would be to use `user_has_cap` - see:
* - https://wordpress.stackexchange.com/a/360990/5380
* - https://developer.wordpress.org/reference/hooks/user_has_cap/
* However, WordPress has a nasty long standing issue with this line:
* - https://bit.ly/3I72jOn
* Where it forces a check to make sure the author is current user, which prevents any efforts to customize capabilities by using a `user_has_cap` filter. The bug is documented here:
@brandonjp
brandonjp / see-wp-db-v1.php
Created November 8, 2025 06:19
WP-Admin plugin to quickly and safely see all database tables and columns - https://snipsnip.pro/s/951
<?php
/**
* Title: See WordPress Database Inside WP-Admin [SnipSnip.pro]
* Description: A simple admin tool to view all database tables, inspect their columns, and preview a few rows of data. No editing or destructive operations — just safe, read-only access for administrators.
* Version: 1.0.0
* Author: Brandon Pfeiffer
* Last Updated: 2025-11-07
* Blog URL: https://snipsnip.pro/s/951
* Requirements: WordPress 6.0+, Administrator role
* License: GPL v2 or later
@brandonjp
brandonjp / WP_Secure_Admin_File_Editor.php
Last active October 31, 2025 04:02
WP_Secure_Admin_File_Editor - PHP Code Snippet [SnipSnip.pro] - https://snipsnip.pro/s/922 - Modern WordPress file editor with JSON validation, auto-backups, and security controls for editing theme.json, plugins, and text files from wp-admin.
<?php
/**
* Title: WordPress Secure File Editor with Theme.json Support
* Description: Adds a comprehensive file editor to WordPress admin for editing theme files, plugin files, and text-based media. Includes special support for theme.json editing with syntax validation and a modern interface with security controls.
* Version: 2.3.0
* Author: SnipSnip Pro
* Last Updated: 2025-10-30
* Blog URL: https://snipsnip.pro/s/922
* Requirements: WordPress 5.9+, PHP 7.4+
* License: GPL v2 or later
@brandonjp
brandonjp / block-editor-auto-expand-advanced-all-sidebar-panels-snipsnip-pro-.code-snippets.json
Created August 8, 2023 16:20
Block Editor: Auto Expand Advanced & All Sidebar Panels [SnipSnip.pro] - When using Gutenberg Block Editor, anytime the content in the sidebar changes, any panels that are closed will open automatically - https://snipsnip.pro/s/751
{
"generator": "Code Snippets v3.4.2.2",
"date_created": "2023-08-08 16:17",
"snippets": [
{
"id": 53,
"name": "Block Editor: Auto Expand Advanced & All Sidebar Panels [SnipSnip.pro]",
"desc": "<p>Block Editor: Auto Expand Advanced &amp; All Sidebar Panels [SnipSnip.pro] - When using Block Editor, anytime the content in the sidebar changes, any panels that are closed will open automatically. <a href=\"https://snipsnip.pro/s/751\">https://snipsnip.pro/s/751</a></p>",
"code": "if (!class_exists('Expand_Sidebar_Panels_On_Mutation')) {\n class Expand_Sidebar_Panels_On_Mutation {\n public function __construct() {\n add_action('admin_footer', array($this, 'add_inline_script'));\n }\n\n public function add_inline_script() {\n if (!function_exists('\\get_current_screen')) {\n return false;\n }\n $screen = \\get_current_screen();\n if (method_exists($screen, 'is_block_editor') && $screen->is_block_editor()) {\n ?>\n <script type=
@brandonjp
brandonjp / WP_Media_Library_GPS_Coordinates_Column.php
Last active August 6, 2025 12:29
Add GPS Coordinates Column to WordPress Media Library [SnipSnip.pro]
<?php
/**
* Title: Add GPS Coordinates Column to WordPress Media Library (Best Version)
* Description: Extracts and displays GPS coordinates from image EXIF data in the media library table view. Robust extraction (multiple fallbacks), developer-configurable UI, admin notice, and copy-to-clipboard functionality.
* Version: 1.6.0
* Author: brandonjp.com
* Last Updated: 2025-06-08
* Blog URL: http://snipsnip.pro/880
* Requirements: WordPress 5.0+
* License: GPL v2 or later
@brandonjp
brandonjp / crowdwork-change-button-texts.js
Created July 28, 2025 18:40
CrowdWork - change the text of any button by specificing in the config of this script
/**
* Button Text Configuration Script
* Version: 2.0.0
*
* Configurable script to change multiple button texts based on matching criteria
*/
(function() {
// Button text replacements
@brandonjp
brandonjp / crowdwork-auto-select-one-ticket.js
Created July 28, 2025 18:27
CrowdWork - on an event page, if there's only one ticket tier, then auto select one ticket
/**
* Auto-select 1 ticket when only one tier is available
* Version: 1.0.0
*/
(function() {
'use strict';
function autoSelectSingleTier() {
// Find all ticket selection containers
@brandonjp
brandonjp / crowdwork-schema.js
Created July 25, 2025 04:00
Schema.org Implementation for CrowdWork Events
/*
* Recommended Schema.org Implementation for CrowdWork Events
* Version: 1.0.0
*
* This script intercepts the API call made by embed.js to generate
* schema.org markup immediately when event data becomes available.
* Place this script BEFORE the embed.js script tag.
*/
// Configuration - UPDATE THESE VALUES FOR YOUR THEATRE
@brandonjp
brandonjp / wp-inspector-enhanced.php
Last active July 2, 2025 13:10
WordPress Post Inspector [SnipSnip.pro] - displays post metadata, SEO information, and WordPress data in a floating panel with admin controls and configuration options. - https://snipsnip.pro/s/884
<?php
/**
* Title: Enhanced WordPress Post Inspector with Admin Controls [SnipSnip.pro]
* Description: A comprehensive debugging tool that displays post metadata, SEO information, and WordPress data in a floating panel. Features configurable position, admin settings, light/dark themes, enhanced data extraction, and security controls for developers.
* Version: 3.2.1
* Author: Brandon Pfeiffer
* Last Updated: 2025-07-01
* Blog URL: https://snipsnip.pro/s/884
* Gist URL: https://gist.github.com/brandonjp/025592669bce65f7031a00f8b04d5c97
* Code Snippets Cloud: https://codesnippets.cloud/snippet/brandonjp/WordPress-Post-541