Skip to content

Instantly share code, notes, and snippets.

View nextab's full-sized avatar

nexTab - Oliver Gehrmann nextab

View GitHub Profile
#region Remove current post from Related Post Query
/**
* Query Loop im Single-Template: aktuellen Beitrag aus post__not_in ausschließen.
* UI vom Query-Block kann post__not_in nicht setzen — daher Filter.
*
* @param array $query Query-Args des Query Loop Blocks.
* @return array
*/
function bartleby_remove_current_post_from_related_post_query( $query ) {
if ( is_admin() || ! is_singular() ) {
@nextab
nextab / .htaccess für das WP uploads Verzeichnis
Created August 7, 2026 14:21
Diese .htaccess Vorlage im /wp-content/uploads Ordner unterbindet die Ausführung von .php Dateien -> falls also ein Virus in deinen uploads-Ordner geladen wurde, kann dieser trotzdem keinen Schaden anrichten.
<FilesMatch "\.(php|php3|php4|phtml)$">
Deny from all
</FilesMatch>
@nextab
nextab / Fix Application Passwords.php
Created August 6, 2026 12:34
minimalistic plugin to allow application passwords in WordPress even when 2 factor authentification hasn't been activated.
<?php
/**
* Plugin Name: Fix Application Password Basic Auth False Positive
*/
add_filter( 'wp_is_site_protected_by_basic_auth', function( $is_protected, $context ) {
if ( 'front' === $context && is_admin() ) {
return false;
}
.grid-container {
/**
* User input values.
*/
--grid-layout-gap: 10px;
--grid-column-count: 4;
--grid-item--min-width: 100px;
/**
* Calculated values.
@nextab
nextab / Fuck Deprecated Messages.php
Created April 6, 2026 14:01
Minimalistic must use plugin for WordPress that disables deprecated messages and error notices that only clog up your debug.log
<?php
/** Plugin Name: Suppress deprecation warnings.
* Description: Put this in .../wp-content/mu-plugins/ to see fewer deprecation warnings.
*/
if ( ! defined( 'ABSPATH' ) ) {
die( 'We\'re sorry, but you can not directly access this file.' );
}
if ( WP_DEBUG ) {
@nextab
nextab / Unique Lines in debug-Datei oder log-Datei herausfinden.md
Created January 31, 2026 20:01
Hast du ein debug-File mit 7000 Zeilen und blickst nicht durch? Dann filtere einmal alle Duplikate (immer wieder dieselbe Meldung) aus dem File und konzentriere dich aufs Wesentliche! Rettet Developer-Leben.

Mit dem Terminal-Command:

tail -n 5000 debug.log | sed 's/^[^]]*] //' | sort | uniq -c | sort -nr

ist es möglich, nur eindeutige Zeilen ausgeben zu lassen (die Timestamps fallen vorne weg), was bedeutet, dass man wesentlich schneller debuggen kann.

#!/bin/bash
#############################################
# WordPress Standard-Installation Script
# Für all-inkl Hosting mit WP CLI
# Version: 3.1 - Multiple Fonts & Colors
#############################################
# Farbcodes für Ausgabe
RED='\033[0;31m'
/* Ggf. anschließend auch noch Permalinks neu abspeichern im WP Backend */
function nxt_clear_theme_json_cache() {
if (function_exists('wp_clean_theme_json_cache')) {
wp_clean_theme_json_cache();
}
delete_transient('global_styles');
delete_transient('global_styles_svg_filters');
wp_cache_flush();
}
@nextab
nextab / CSS
Created November 19, 2025 21:04
Code-Snippets für ein ausfahrbares Kontaktformular in WordPress (Divi Theme)
body.slide-form-open {
overflow: hidden;
overscroll-behavior: none;
touch-action: none;
}
/* #region Slide In Contact Form */
.et_pb_section.slide_in_contact_form {
height: 100%;
left: auto;
max-width: 440px;
<?php
global $post;
$post_parent = $post->post_parent;
if ( $post_parent ){
wp_redirect(get_permalink($post_parent));
} else {
$home_url = home_url();
wp_redirect( $home_url);
}
?>