Skip to content

Instantly share code, notes, and snippets.

View nextab's full-sized avatar

nexTab - Oliver Gehrmann nextab

View GitHub Profile
<?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);
}
?>
@nextab
nextab / Clamp-Funktion in SCSS.scss
Created June 20, 2025 16:14
Funktionsweise: h1 { font-size: create-clamp(40px, 20px); }
/* #region Clamp Function for Responsive Typography */
$clamp-view-min: 400;
$clamp-view-max: 1100;
$clamp-default-unit: rem;
$clamp-base-font-size: 16; // Base font size in px for rem conversion
@function strip-units($value) {
@if unitless($value) {
@return $value;
}
(function() {
// Variables to track scroll state and rotation
let lastScrollTop = 0;
let scrollTimeout;
let rotationAngles = {}; // Store rotation angles for each SVG
const ROTATION_SPEED = 0.5; // Degrees per scroll event
let animatedSections = new Map(); // Track sections being animated
// Function to get or initialize rotation angle for an element
function getRotationAngle(element) {
@nextab
nextab / ::after Elemente für Links (mehr Barrierefreiheit).css
Created May 8, 2025 09:57
Mit der CSS Klasse "tolle-links" sorgt man dafür, dass ein Icon nach einem Link im Text erscheint, um so dafür zu sorgen, dass auch farbenblinde Menschen kein Problem damit haben, den Link zu identifizieren.
// In die Design-Einstellungen -> CSS von der ZEILE!
@media (min-width: 981px) {
selector .et_pb_column {
display: flex;
flex-flow: column nowrap;
align-items: flex-start;
justify-content: center;
gap: 0;
}
@nextab
nextab / functions.php Vorlage für ein Child Theme (für Divi)
Created April 18, 2025 11:56
Diverse Hacks und Vorlagen für ein besseres und sichereres WordPress
<?php
#region Clean Up WP Admin Bar
function remove_admin_bar_links() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo'); // Remove the Wordpress logo + sub links
// $wp_admin_bar->remove_menu('site-name'); // Remove the site name menu
// $wp_admin_bar->remove_menu('view-site'); // Remove the view site link
// $wp_admin_bar->remove_menu('updates'); // Remove the updates link
// $wp_admin_bar->remove_menu('comments'); // Remove the comments link
$wp_admin_bar->remove_menu('new-content'); // Remove the content link
<?php
// Get all ACF fields of the current post
$custom_fields = get_fields();
$available_fields = array();
if ($custom_fields) {
foreach ($custom_fields as $field_name => $field_value) {
$available_fields[$field_name] = $field_value;
}
}
(function() {
// Add scroll class to body when scrolling
function handleScroll() {
const scrollPosition = window.scrollY || document.documentElement.scrollTop;
if (scrollPosition > 0) {
document.body.classList.add('scrolling');
} else {
document.body.classList.remove('scrolling');
}
@nextab
nextab / Gutenberg für Posts deaktivieren.php
Created March 7, 2025 11:19
Kurzes Snippet für die functions.php des Child Themes in WordPress, um den Gutenberg Block Editor für Beiträge zu deaktivieren.
add_filter( 'use_block_editor_for_post', '__return_false' );
@nextab
nextab / Relevanssi Live Ajax Search Template.php
Created February 5, 2025 17:49
Vorlage für ein benutzerfreundlicheres Such-Ergebnis für die Live-Ajax-Ergebnisse des Plugins Relevanssi
<?php
/**
* Search results template
* @package Relevanssi Live Ajax Search
*/
function get_custom_post_type_labels() {
return array(
'projects' => 'Projekte',
'post' => 'Neuigkeiten',