Skip to content

Instantly share code, notes, and snippets.

View dknauss's full-sized avatar

Dan Knauss dknauss

View GitHub Profile
<?php
class Joost_Comment_Fixes {
public function __construct() {
// Unhook comment cookies stuff from core.
remove_action( 'set_comment_cookies', 'wp_set_comment_cookies' );
add_action( 'wp_footer', [ $this, 'print_custom_comment_script' ] );
add_filter( 'wp_get_current_commenter', [ $this, 'ignore_comment_cookies_serverside' ] );
add_filter( 'comment_post_redirect', [ $this, 'comment_moderation_redirect' ], 10, 2 );
@adrienne
adrienne / mullenweg-wpe.md
Last active November 22, 2025 13:16
The Mullenweg/WPE Thing
@dknauss
dknauss / wp-disable-login-form.php
Last active February 9, 2025 21:48 — forked from daggerhart/wp-disable-login-form.php
The WordPress login form never loads unless a "secret" key-value pair exists as a URL parameter.
add_filter( 'wp_login_errors', 'login_form_lockdown', 90, 2 );
/**
* This code locks down the WordPress login form by hijacking the page via the 'wp_login_errors' hook and only executing the
* login header, footer, and necessary closing tags unless a URL parameter (defined in the function) is included in the request.
* If the parameter exists, the full login form is returned in the error object.
*
* Without the "secret" key-value pair passed as a URL parameter, all login pages will be blank except for any HTML/CSS loaded
* prior to wp_login_errors, such as the default wordpress.org-linked WordPress logo above the (absent) login form.
*
@tomfinitely
tomfinitely / multisite-reusable-blocks.php
Created June 20, 2024 15:43
Synchronize Reusable Blocks Between WordPress Multisite Subsites
/**
* Sync the reusable blocks between the sites of the multisite.
*
* @param int $post_id The post id.
* @param WP_Post $post The post object.
*/
add_action( 'publish_wp_block', 'slug_sync_reusable_blocks', 10, 2 );
function slug_sync_reusable_blocks( $post_id, $post ) {
// Check if the post already has a sync_hash or create one.
if ( get_post_meta( $post_id, 'sync_hash', true ) !== '' ) {
@afragen
afragen / gist-oembed.php
Last active August 5, 2022 19:56
WordPress plugin to embed gists or gist files.
<?php
/**
* Gist oEmbed.
*
* @package Fragen\Gist_OEmbed
*
* Plugin Name: Gist oEmbed
* Plugin URI: https://gist.github.com/afragen/36ab01da116aadd27a3f4d85cce90390
* Description: oEmbed Gist or files within Gists.
* Version: 0.6.2
@cranelab
cranelab / gist:940d76283414908b464074dba1aaa7af
Created February 2, 2022 18:19
all wp plugins with over 100+ active installations
5,000,000+ : wpforms-lite
5,000,000+ : wordpress-seo
5,000,000+ : woocommerce
5,000,000+ : really-simple-ssl
5,000,000+ : jetpack
5,000,000+ : elementor
5,000,000+ : contact-form-7
5,000,000+ : classic-editor
5,000,000+ : akismet
4,000,000+ : wordpress-importer
@rosswintle
rosswintle / build.php
Last active December 12, 2025 14:12
A VERY simple PHP static HTML generator that does a single-level extend, and includes with variable passing and that's about it.
<?php
/*
* Input: files matching src/pages/*.html
* Output: public/*.html
*
* Pages can extend a template by calling:
*
* extend(string $relativeTemplatePath, array $variables)
*
* at the start and:
@premek
premek / mv.sh
Last active March 5, 2024 17:43
Rename files in linux / bash using mv command without typing the full name two times
# Put this function to your .bashrc file.
# Usage: mv oldfilename
# If you call mv without the second parameter it will prompt you to edit the filename on command line.
# Original mv is called when it's called with more than one argument.
# It's useful when you want to change just a few letters in a long name.
#
# Also see:
# - imv from renameutils
# - Ctrl-W Ctrl-Y Ctrl-Y (cut last word, paste, paste)
@sleepyfox
sleepyfox / 2019-07-25-users-hate-change.md
Last active October 25, 2025 18:39
'Users hate change'

'Users hate change'

This week NN Group released a video by Jakob Nielsen in which he attempts to help designers deal with the problem of customers being resistant to their new site/product redesign. The argument goes thusly:

  1. Humans naturally resist change
  2. Your change is for the better
  3. Customers should just get used to it and stop complaining

There's slightly more to it than that, he caveats his argument with requiring you to have of course followed their best practices on product design, and allows for a period of customers being able to elect to continue to use the old site, although he says this is obviously only a temporary solution as you don't want to support both.

@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active October 28, 2025 06:41
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}