Skip to content

Instantly share code, notes, and snippets.

Avatar
🤔
Overthinking things since 1978

Torsten Landsiedel Zodiac1978

🤔
Overthinking things since 1978
View GitHub Profile
@Zodiac1978
Zodiac1978 / functions.php
Created Jul 15, 2022
Preloading block styles to make WordPress sites faster
View functions.php
<?php
/**
* Add some preloading
* @link: https://www.phpied.com/faster-wordpress-rendering-with-3-lines-of-configuration/
*/
function hints() {
$wp_version = get_bloginfo( 'version' );
header( 'link: </wp-includes/css/dist/block-library/style.min.css?ver=' . $wp_version . '>; rel=preload' );
}
add_action( 'send_headers', 'hints' );
@Zodiac1978
Zodiac1978 / add_body_class_if_title_hidden.php
Last active Mar 16, 2022
Add body class if title is hidden in GeneratePress (https://generatepress.com/)
View add_body_class_if_title_hidden.php
<?php
/**
* Add body class if title is hidden.
*
* @param array $classes An array of body class names.
* @return array An array of body class names with added class name if title is hidden.
*/
function add_body_class_if_title_hidden( $classes ) {
if ( ! generate_show_title() ) {
$classes[] = 'gp-title-hidden';
@Zodiac1978
Zodiac1978 / wp-config.php
Created Mar 4, 2022
Log errors in debug.log in /wp-content-folder on production server (prevent public access to this file!)
View wp-config.php
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', false );
define( 'WP_DEBUG_LOG', true );
@Zodiac1978
Zodiac1978 / .htaccess
Last active Mar 4, 2022
Redirect from http to https
View .htaccess
# Redirect from http to https
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
@Zodiac1978
Zodiac1978 / custom-pattern.php
Last active May 16, 2021
Custom Pattern for Antispam Bee: Invalid URL and only one word as name and in content
View custom-pattern.php
<?php
/**
* Plugin Name: Custom Patterns for Antispam Bee
* Description: Add custom patterns for Antispam Bee.
* Plugin URI: https://torstenlandsiedel.de
* Version: 1.0
* Author: Torsten Landsiedel
* Author URI: https://torstenlandsiedel.de
* Licence: GPL 2
* License URI: http://opensource.org/licenses/GPL-2.0
@Zodiac1978
Zodiac1978 / style.css
Last active Mar 13, 2021
Responsiveness Spalten-Block anpassen - CSS-Lösung für das hier beschriebene Problem: https://die-netzialisten.de/responsiveness-spalten-block-anpassen/
View style.css
/*
Sources:
https://stackoverflow.com/questions/8720931/can-css-detect-the-number-of-children-an-element-has
https://lea.verou.me/2011/01/styling-children-based-on-their-number-with-css3/
*/
@media (min-width:600px) and (max-width:781px) {
.wp-block-column:first-child:nth-last-child(3) {
flex-basis: 100% !important;
}
@Zodiac1978
Zodiac1978 / functions.php
Created Feb 8, 2021
Remove divi shortcodes from attached pages in Germanized for Woocommerce plugin mails
View functions.php
<?php
/**
* Just return the content
*
* @param [string] $atts Unused attributes.
* @param [string] $content Submitted content.
* @return [string] Unmodified content with shortcodes because of nested shortcodes.
*/
function divi_remove_shortcodes( $atts, $content ) {
@Zodiac1978
Zodiac1978 / custom-editor-style.css
Last active Feb 4, 2021
Override editor colors in (twenty eleven) child theme
View custom-editor-style.css
/*
Theme Name: Twenty Eleven
Description: Custom colors.
*/
body {
color: #fff;
background: #ddd;
}
@Zodiac1978
Zodiac1978 / projekt26-2021.md
Last active Nov 25, 2021
Teilnehmerinnen und Teilnehmer sowie alle Beiträge zur #Projekt26 Challenge im Jahr 2021
View projekt26-2021.md

Am 28.12.2019 habe ich mit einem Tweet zur #Projekt26 Challenge herausgefordert. Alle zwei Wochen bloggen und kommentieren, über Wordpress oder Verwandtes, in Deutsch oder Englisch. Auch in 2021 geht es weiter!

Alle Details dazu in diesem Artikel: https://torstenlandsiedel.de/2019/12/28/projekt26-jetzt-erst-recht/

Und das Fazit aus dem Jahr 2020: https://torstenlandsiedel.de/2020/12/13/das-projekt26-geht-bald-zu-ende/

KW 27+28

KW 25+26

@Zodiac1978
Zodiac1978 / sample.html
Last active Mar 31, 2022
Gutenberg sample content ased on https://artisanthemes.io/sample-content-blocks-gutenberg/ but with working placeholders (WIP)
View sample.html
<!-- wp:paragraph {"align":"center","backgroundColor":"very-light-gray","fontSize":"small"} -->
<p class="has-text-align-center has-very-light-gray-background-color has-background has-small-font-size"><p style="color:#000000;text-align:center" class="has-background has-small-font-size has-very-light-gray-background-color">Gutenberg Sample Content.<br>Put together with ❤️ by <a href="https://artisanthemes.io/">Artisan Themes</a> and me.</p></p>
<!-- /wp:paragraph -->
<!-- wp:heading {"level":1} -->
<h1>This is a heading (H1)</h1>
<!-- /wp:heading -->
<!-- wp:heading -->
<h2>This is a heading (H2)</h2>