Skip to content

Instantly share code, notes, and snippets.

@majick777
majick777 / clean-post-scripts.php
Created August 24, 2023 12:29
Clean All Script Tags from Posts
<?php
// ================================
// CLEAN ALL SCRIPT TAGS FROM POSTS
// ================================
//
// Usage: Drop this file in your /wp-content/mu-plugins/ folder.
//
// Any post or page that contains a script tag will have it removed automatically.
// This helps prevent re-infection while hardening your site security.
@majick777
majick777 / autosplit-admin-menu.php
Last active October 22, 2019 17:24
Auto Split WordPress Admin Menu
<?php
// -----------------------------
// === Auto Split Admin Menu ===
// -----------------------------
// Automatically splits WordPress Admin Menus into 3 sections:
// A = Dashboard and Post Type Menus
// B = All Other Default WordPress Menus
// C = Any Other Added Menu Items
<?php
// ------------------------
// Email Image AutoEmbedder
// ------------------------
add_action('phpmailer_init', 'email_images_embedder');
function email_images_embedder($phpmailer) {
@majick777
majick777 / administrator-whilelist.php
Created December 15, 2017 23:30
Automatically deletes any administrator accounts not in hardcoded whitelist.
<?php
/* === AutoDelete new Administrators === */
/* (last line of defence against hackers) */
/* Usage: 1. set the admin username list to existing real admin(s) */
/* 2. place this file in your /wp-content/mu-plugins/ directory */
/* 3. remember to update the username list if you add a new admin */
/* 4. harden your security in other ways - do not rely on this */
@majick777
majick777 / wp-delete-post-attachments.php
Last active December 1, 2017 01:25
Function to Delete All Attachments for a Post
// Delete All Attachments for a Specified Post
// -------------------------------------------
function wp_delete_post_attachments($post, $deletethumbnail = false);
if (!is_object( $post )) {$post = get_post( $post );}
$uploads = wp_upload_dir();
$args = array(
'post_type' => 'attachment',
@majick777
majick777 / wp-debug-session.php
Last active May 29, 2022 11:17
Enables setting WordPress Debug, Debug Logging and Debug Display via Querystring.
<?php
/* ================ */
/* WP Debug Session */
/* ---------------- */
/* . Version 1.04 . */
/* ================ */
// Home: https://gist.github.com/majick777/6c4e4074ce4a59fe09f7baa855732aee
// Author: DreamJester of http://wordquest.org/