Skip to content

Instantly share code, notes, and snippets.

View kmwalsh's full-sized avatar
🤖

Kate Walsh kmwalsh

🤖
View GitHub Profile
@kmwalsh
kmwalsh / admin-menu.php
Created April 29, 2025 19:31 — forked from mehrshaddarzi/admin-menu.php
debug get all list menu in admin wordpress
<?php
/*
Check class Adctie Menu Admin
//is_open => wp-has-current-submenu wp-menu-open
//is_open for menu who not submenu => current
//is_close => wp-not-current-submenu menu-top
//if for post Type li => id="menu-posts-{post_type_name}"
//if for taxonomy => id="toplevel_page_edit-tags-taxonomy-{taxonomy}-post_type-{posttype}"
*/
## powershell - remove everything in a filename up to the first dash
## useful when emoji are named 392394-something-something.png
foreach ($file in (get-childitem *.png).name) {
Rename-Item $file ($file -replace '^[^-]*-\s*')
}
## powershell - transform underscores to dashes
Get-ChildItem *.png | Rename-Item -NewName { $_.Name -replace '_','-' }
@kmwalsh
kmwalsh / gist:371ff5d691e270667417718916f62247
Created October 28, 2024 18:16
wp sql query - get all revisions prior to a specific date, unique to post ID
select ID,post_author,post_title,post_parent from `wp_posts` where `post_type` = 'revision' AND `post_date` <= '2024-10-16 00:00:00' AND post_parent IN (SELECT post_parent FROM (SELECT post_parent, COUNT(post_parent) FROM wp_posts
GROUP BY post_parent
HAVING COUNT(post_parent) = 1) AS subQuery);
<?php
/**
* Check ACF Field Use
*
* Plugin Name: Check ACF Field Use
* Plugin URI: https://wordpress.org/plugins/check-acf-field-use/
* Description: Check how many times an ACF field is used across your site, get useful data, post links, etc.
* Version: 1.0.0
* Author: KMW
@kmwalsh
kmwalsh / gist:89562fd8468fd91c68d84d10f17988cb
Created September 13, 2024 18:10
mysql query to get post ID, title, etc. from wp postmeta where you have flexible content with a numeric ID value
/**
* - Flexible Content created with ACF
* - Field that lets you select a Gravity Form, loads the GF ID for use in templates (can replace this with whatever, as long as the meta value assignment is to an ID)
* - Query lets you get a list of all posts using the flex content to display the form
*/
SELECT DISTINCT ID, post_title, post_status, guid, meta_value from `wp_posts`
LEFT JOIN `wp_postmeta` ON `post_id` = `ID`
WHERE `post_status` = 'publish' AND `meta_key` LIKE '%gravity_form%' AND `meta_value` REGEXP '^[0-9]+$';
/**
* SearchWP relevant customization.
*
* @package lnct
*/
class LNCT_SearchWP {
public function __construct() {
add_filter( 'searchwp_live_search_query_args', [ $this, 'restrict_searchwp_post_types'] );
@kmwalsh
kmwalsh / gist:2f2f3e0d46681bae34aedc31e65a0115
Created March 8, 2024 19:44
Fix inaccurate comment counts across a WP multisite via wp cli
/**
* Fix inaccurate comment counts across a WP multisite
*
*/
class Multisite_Comments_Fix {
/**
* Class construction.
*/
@kmwalsh
kmwalsh / slack-analgesic.css
Last active February 26, 2024 17:44
Make Slack less painful.
/* ==UserStyle==
@name slack.com - 6/6/2023, 6:08:37 PM
@namespace github.com/openstyles/stylus
@version 1.0.0
@description A Slack in-browser customization style
@author github.com/kmwalsh
==/UserStyle== */
@-moz-document domain("app.slack.com") {
* {
@kmwalsh
kmwalsh / automatically prepend ticket number to commit message
Last active December 11, 2023 17:40
automatically prepend ticket number to commit message
* mv .git/hooks/commit-msg.sample .git/hooks/commit-msg
* chmod ug+x .git/hooks/commit-msg
paste the desired script into commit-msg
Use this template when reporting a security vulnerability in Slack.
It can be inefficient to have to dig through a thread to figure out
what to do next. Presenting all of the information in the initial
disclosure message is ideal. Additionally, it is harrowing to
receive notification of a security vulnerability and can cause much
strife and chaos and confusion. This prevents some emotional chaos.
---
**Plugin:** (link to plugin repo)