Skip to content

Instantly share code, notes, and snippets.

View mindctrl's full-sized avatar

John Parris mindctrl

View GitHub Profile
@mindctrl
mindctrl / remove-wp-mail-smtp-submenus.php
Created March 4, 2025 16:04
Remove spammy WP-Mail-SMTP submenus
<?php
add_action( 'admin_menu', function() {
remove_submenu_page( 'wp-mail-smtp', 'wp-mail-smtp-reports' );
remove_submenu_page( 'wp-mail-smtp', 'wp-mail-smtp-logs' );
remove_submenu_page( 'wp-mail-smtp', 'wp-mail-smtp-about' );
remove_submenu_page( 'wp-mail-smtp', 'manage_options' );
global $submenu;
unset( $submenu['wp-mail-smtp'][5] );
}, 100 );
@mindctrl
mindctrl / dev-site-blogname.php
Created February 21, 2025 18:37
Prepends "(DEV)" to blog name
add_filter( 'option_blogname', 'jp_dev_blogname' );
/**
* Prepend '(DEV) ' to blog name
*/
function jp_dev_blogname( $value ): string {
return '(DEV) ' . $value;
}
@mindctrl
mindctrl / organize-wp-admin-menu-sidebar.php
Created January 17, 2025 17:10
Move all non-core WordPress admin menu items to the bottom of the sidebar
<?php
add_action( 'admin_menu', 'jp_reorder_admin_menu', 999 );
/**
* Reorder wp-admin sidebar menus
*/
function jp_reorder_admin_menu() {
global $menu;
if ( empty( $menu ) ) {
return;
}
@mindctrl
mindctrl / customize-genesis-blocks-menu.php
Created January 13, 2025 21:16
Move Genesis Blocks wp-admin menu to the bottom
<?php
add_action( 'admin_menu', function() {
global $menu;
// Find the Genesis Blocks menu (genesis-blocks-getting-started)
$genesis_blocks_menu = false;
foreach ( $menu as $key => $menu_item ) {
if ( $menu_item[2] === 'genesis-blocks-getting-started' ) {
$genesis_blocks_menu = $menu[$key];
unset( $menu[$key] ); // Remove it from the current position
@mindctrl
mindctrl / move-jetpack-menu.php
Created January 9, 2025 18:00
Move Jetpack menu to bottom of wp-admin
<?php
add_action( 'admin_menu', function() {
global $menu;
// Find the Jetpack menu
$jetpack_menu = false;
foreach ( $menu as $key => $menu_item ) {
if ( $menu_item[2] === 'jetpack' ) {
$jetpack_menu = $menu[$key];
unset( $menu[$key] ); // Remove it from the current position
@mindctrl
mindctrl / customize-wpforms-menu.php
Created January 8, 2025 02:29
Move and rename WPForms menu in wp-admin
<?php
add_action( 'admin_menu', function() {
global $menu;
// Find the WPForms menu (wpforms-overview)
$wpforms_menu = false;
foreach ( $menu as $key => $menu_item ) {
if ( $menu_item[2] === 'wpforms-overview' ) {
$wpforms_menu = $menu[$key];
unset( $menu[$key] ); // Remove it from the current position
@mindctrl
mindctrl / jp-disable-some-plugin-updates.php
Created September 11, 2024 17:06
Programmatically disable updates for specific WordPress plugins
<?php
/**
* Plugin Name: JP Plugin Update Disabler
* Description: Disables plugin updates for specified plugins.
* Version: 1.0
* Author: John Parris
*/
add_filter( 'http_request_args', 'jp_disable_plugin_updates', 10, 2 );
function jp_disable_plugin_updates( $args, $url ) {
if ( str_starts_with( $url, 'https://api.wordpress.org/plugins/update-check/1.1/' ) ) {
@mindctrl
mindctrl / whatever.js
Created September 11, 2024 17:00
JavaScript to unsubscribe from GitHub comments/issues/PRs/whatever
// Why? Because GitHub's UI only allows 25 at a time, and doing it manually with a mouse is annoying.
// With this you can just paste in the console and press enter, wait for reload, do it again.
// I'm sure there's a "better" way, but I did not want to dive into their API docs for a one-time thing.
// Click the Select All checkbox
var el = document.querySelector('[aria-labelledby="select-all-subscriptions-text"]');
el.click();
// Click the Unsubscribe button
var un = document.querySelector('button.ml-3');
@mindctrl
mindctrl / remove-wpforms-menus.php
Created September 5, 2024 01:18
Remove WPForms admin menu spam
<?php
add_action( 'admin_menu', function() {
remove_submenu_page( 'wpforms-overview', 'wpforms-analytics' );
remove_submenu_page( 'wpforms-overview', 'wpforms-smtp' );
remove_submenu_page( 'wpforms-overview', 'wpforms-about' );
remove_submenu_page( 'wpforms-overview', 'wpforms-community' );
}, 100 );
@mindctrl
mindctrl / enqueue-react-devtools-script.php
Last active May 23, 2022 14:28
Using React Dev Tools (react-devtools) with WordPress and Safari
<?php
// This loads the react-devtools script in wp-admin when using Safari.
add_action( 'admin_enqueue_scripts', function() {
if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) && strpos( $_SERVER['HTTP_USER_AGENT'], 'Safari' ) !== false ) {
?>
<script src="http://localhost:8097"></script>
<?php
}
} );