Skip to content

Instantly share code, notes, and snippets.

View mainiomooses's full-sized avatar
😵
<-- Constantly that

Jaakko Pöntinen mainiomooses

😵
<-- Constantly that
View GitHub Profile
@mainiomooses
mainiomooses / no-user-enumeration.php
Created June 24, 2026 08:54
WP Plugin: No User Enumeration
<?php
/**
* Plugin Name: No User Enumeration
* Description: Network-wide hardening: strip user-enumeration vectors from
* REST, oembed, feeds, author archives, sitemaps, and the
* REST API root index. Admin-context callers that genuinely
* need /wp/v2/users (Gutenberg author selector, plugins doing
* user search) keep access via an `edit_posts` capability
* check.
* Author: Jaakko Pöntinen (Mainio Mooses)
<?php
if (is_single()) {
if( has_term('', 'sijainti', $post->ID) ){
$sijainnit = wp_get_post_terms( $post->ID, 'sijainti' );
$target = $sijainnit[0]->term_id;
if (in_array($target, $gifts_valid_locations)) {
$mm_donation__gift_key = array_search($target, $gifts_valid_locations);
return $gifts[$mm_donation__gift_key];
}
$target_progenitor = $target;
<?php
/**
* Debug helper, place near the top of your functions.php
* Use with write_log($var) to write $var contents into debug.log
*/
function write_log( $data ) {
if ( true === WP_DEBUG ) {
if ( is_array( $data ) || is_object( $data ) ) {
error_log( print_r( $data, true ) );
} else {
@mainiomooses
mainiomooses / gf.php
Last active November 13, 2023 16:11
GFAPI::get_entries usage with is_read and is_starred field filters alongside other filters
<?php
// Correct way to use "is_read" and/or "is_starred" with GFAPI::get_entries
$search_criteria = array(
'status' => 'active',
'field_filters' => array(
'mode' => 'all',
array(
'key' => '8',
'value' => 'abc',