Skip to content

Instantly share code, notes, and snippets.

@brandonjp
brandonjp / moment-formats.md
Last active May 1, 2025 13:23
List of common date time formats for Moment.js

Big List of Common Moment.JS Date and Time Formats for Easy Copying

Example Format
2021 YYYY
🦏 🦏
202108 YYYYMM
2021-08 YYYY-MM
🦏 🦏
8/5 M/D
08/05 MM/DD
@brandonjp
brandonjp / findOverflowParents.js
Last active April 15, 2025 11:03
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-bulk-plugin-uploader.php
Last active April 10, 2025 17:24
Upload multiple WordPress plugins at once using a single ZIP file or several. You can select multiple zips. You can upload a big zip that contains multiple plugin zips or folders. You can set them all to auto-update, activate, replace existing, etc. Pretty cool! More info here: https://snipsnip.pro/s/868
<?php
/*
* Plugin Name: Bulk Plugin Upload
* Description: Upload multiple WordPress plugins at once using a single ZIP file or several.
* Excerpt: Improve native WordPress plugin uploading with this Bulk Plugin Uploader which allows you to upload multiple WordPress plugins at once. You can select several individual ZIP files for upload, or choose a single ZIP that contains multiple plugins—either as separate folders or nested ZIPs. This user-friendly tool simplifies plugin management, making it quick and easy to install, activate, and set up auto-updates for your plugins. Perfect for novice users looking to streamline their WordPress site management!
* Version: 2.3.0
* Author: brandonjp.com
* License: GPL v2 or later
* Text Domain: bulk-plugin-upload
*
@brandonjp
brandonjp / media-library-double-click-selection.php
Created February 19, 2025 05:30
Media Library Double-Click Selection [SnipSnip.pro] - https://snipsnip.pro/s/858 - Enhances the WordPress Media Library modal by enabling double-click to select and confirm media items. Double-clicking an image automatically selects it and triggers the select/insert button, streamlining the media selection workflow.
<?php
/**
* Title: Media Library Double-Click Selection [SnipSnip.pro]
* Description: Enhances the WordPress Media Library modal by enabling double-click to select and confirm media items. Double-clicking an image automatically selects it and triggers the select/insert button, streamlining the media selection workflow.
* Version: 2.2.0
* Author: brandonjp.com
* Last Updated: 2025-02-18
* Blog URL: https://snipsnip.pro/s/858
* Requirements: WordPress 5.0 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 / Deactivate_Plugins_On_Staging.php
Created January 28, 2024 00:22
Deactivate Specific Plugins on Staging & Non-Production Sites [SnipSnip.pro] - https://snipsnip.pro/s/827
/**
* Deactivate Specific Plugins on Staging & Non-Production Sites [SnipSnip.pro] - https://snipsnip.pro/s/827
*/
if (!class_exists('Deactivate_Plugins_On_Staging')) {
/**
* Selectively deactivates plugins on staging and similar environments.
*/
class Deactivate_Plugins_On_Staging {
private $stagingKeywords = ['staging', 'dev', 'local', 'test', 'sandbox', 'demo'];
private $forceDeactivations = false; // Set to true to deactivate regardless of environment detection.
@brandonjp
brandonjp / Deactivate_Plugins_On_Production.php
Last active January 28, 2024 00:21
Deactivate Specific Plugins on Production Sites [SnipSnip.pro] - https://snipsnip.pro/s/825
/**
* Deactivate Specific Plugins on Production Sites [SnipSnip.pro] - https://snipsnip.pro/s/825
*/
if (!class_exists('Deactivate_Plugins_On_Production')) {
/**
* Selectively deactivates plugins on production environments.
*/
class Deactivate_Plugins_On_Production {
private $stagingKeywords = ['staging', 'dev', 'local', 'test', 'sandbox', 'demo'];
private $forceDeactivations = false; // Set to true to deactivate regardless of environment detection.
@brandonjp
brandonjp / ScreenshotTimer.scpt
Last active December 26, 2023 22:50 — forked from jonobr1/auto-capture.scpt
A small AppleScript to take a screenshot every X minutes and run for Y hours. Saves to an Image with datetime to your specified folder. Great for recording your workday.
set dir to "~/Dropbox/Dropbox2/ScreenshotTimer/"
do shell script ("mkdir -p " & dir)
set intervalMins to 15 -- Change as per your desired frequency (in minutes)
set durationHours to 8 -- Change as per your desired duration (in hours)
-- Convert minutes to seconds for screenshot interval
set intervalSecs to intervalMins * 60
-- Calculate total repetitions within duration
set totalReps to durationHours * 60 / intervalMins
@brandonjp
brandonjp / this-breaks-csp.php
Last active October 16, 2023 16:51
this breaks code snippets pro - if either line 12 or 38 is removed, the snippet will save. But if both lines are present, an error is returned when saving: "Could not update snippet. Request failed with status code 418" - as of code_snippets_version: 3.5.1
if(!class_exists('WPOptionsViewPage')) {
class WPOptionsViewPage {
public function __construct() {
}
public function add_submenu_page() {
}
public function display_options_page() {
@brandonjp
brandonjp / block-editor-open-advanced-on-mouseenter-code-snippets.json
Last active August 8, 2023 16:29
Wordpress Gutenberg Block Editor: Keep Advanced Section Always Open
{
"generator":"Code Snippets v3.3.0",
"date_created":"2023-04-08 21:52",
"snippets":[
{
"name":"Block Editor: Open Advanced Panel on Hover [SnipSnip.pro]",
"desc":"When using Gutenberg Block Editor, anytime your mouse enters the sidebar panel, if the \u201cAdvanced\u201d section is not open, then expand it. (Causes a minor annoyance where it scrolls to Advanced after expanding it.) (Includes a delay to ensure the sidebar is rendered... you might need to adjust the setTimeout delay if your site\/browser is slow to load the Block Editor.)\n\nCode revisions at: <a href=\"https:\/\/gist.github.com\/brandonjp\/bcfd56838359f12ef5c3ed2ecb6132dc\">https:\/\/gist.github.com\/brandonjp\/bcfd56838359f12ef5c3ed2ecb6132dc<\/a>\n\n<a href=\"https:\/\/snipsnip.pro\/s\/177\">https:\/\/snipsnip.pro\/s\/177<\/a>",
"tags":[
"admin",
"gutenberg",