Skip to content

Instantly share code, notes, and snippets.

View Zodiac1978's full-sized avatar
🤔
Overthinking things since 1978

Torsten Landsiedel Zodiac1978

🤔
Overthinking things since 1978
View GitHub Profile
@mathetos
mathetos / plugin.php
Last active April 9, 2024 17:10
Get User Admin Color Schemes for UI styling
<?php
// Add Current Users Admin Color Scheme
// 1. Create helper function to grab individual colors easily
// 2. Add individual colors to document root as CSS variables
function wpptpcv_return_admin_colors() {
global $_wp_admin_css_colors;
// Get the user's selected color scheme name
@jb510
jb510 / snippet.php
Created February 29, 2024 05:48
Add "Manage Patterns" menu item under Pages
<?php
/**
* Adds a menu item to the admin menu for managing patterns
*/
function s9_add_manage_patterns_menu() {
// Check if the current user has the capability to edit pages
if (!current_user_can('edit_pages')) {
return;
}
<?php
/**
* Render the schema graph for the acf/gb-faq block.
*
* @param array $graph Schema data for the current page.
* @param WP_Block_Parser_Block $block The block data array.
* @param Meta_Tags_Context $context A value object with context variables.
*
* @return array Our Schema graph.
*/
@florianbrinkmann
florianbrinkmann / functions.php
Created March 13, 2021 12:55
Add has-\d-columns class to columns blocks after 5.3 update.
<?php
/**
* Add has-\d-columns class to columns blocks after 5.3 update.
*
* @param string $block_content The block content about to be appended.
* @param array $block The full block, including name and attributes.
*
* @return string
*/
add_filter( 'render_block', function( $block_content, $block ) {
@walterebert
walterebert / functions.php
Last active October 14, 2021 17:24
WordPress: Don't use cookies with YouTube
<?php
/*
Use YouTube privacy-enhanced mode. More info: https://support.google.com/youtube/answer/171780?visit_id=637419781721286051-946666784&rd=1
*/
add_filter(
'embed_oembed_html',
function( $cache, $url, $attr, $post_ID ) {
if ( preg_match('#^https?://(www\.)?youtu\.?be(\.com)?/#i', $url) ) {
return str_replace(
' src="https://www.youtube.com/embed/',
@webdados
webdados / remove_wp_54_favicon.php
Last active December 29, 2021 20:42
Do not show WordPress 5.4 default WP blue favicon
<?php
//Inspiration: https://gist.github.com/florianbrinkmann/a879099f3d28c5e1d64f2aeea042becf
add_action( 'do_faviconico', function() {
//Check for icon with no default value
if ( $icon = get_site_icon_url( 32 ) ) {
//Show the icon
wp_redirect( $icon );
} else {
//Show nothing
header( 'Content-Type: image/vnd.microsoft.icon' );
@ismyrnow
ismyrnow / mac-clear-icon-cache.sh
Created May 5, 2017 19:28
Clear the icon cache on a Mac when you start seeing generic icons in Finder or the Dock
sudo rm -rfv /Library/Caches/com.apple.iconservices.store; sudo find /private/var/folders/ \( -name com.apple.dock.iconcache -or -name com.apple.iconservices \) -exec rm -rfv {} \; ; sleep 3;sudo touch /Applications/* ; killall Dock; killall Finder
@Drivingralle
Drivingralle / enqueue-styles-with-right-version.php
Created December 1, 2016 15:06
WordPress | Enqueue scripts/styles automaticly using right version number from parent-/child-theme
<?php
/*
* Enqueue parent and child theme style.css
*/
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles', 20 );
function my_theme_enqueue_styles() {
// Get the theme data
$my_theme = wp_get_theme();
<?php
/**
* Capitalize ẞ Dangit
*
* @package CapitalizeẞDangit
* @author Bernhard Kau
* @license GPLv3
*
* @wordpress-plugin
* Plugin Name: Capitalize ẞ Dangit
@glueckpress
glueckpress / function-body-class-active-menus.php
Last active July 5, 2018 20:30
[WordPress][functions] Add body classes for active menu locations and active widget areas. In reply to this post (🇩🇪): http://torstenlandsiedel.de/2016/05/01/css-klasse-hinzufuegen-fuer-mobilgeraete/
<?php
/**
* Alters body class for populated menu locations.
* @param array $classes Registered body classes
* @return array Altered body classes
*/
function ch20160502__body_class_active_menus( $classes ) {
$menu_locations = get_nav_menu_locations();