Skip to content

Instantly share code, notes, and snippets.

@hostz-frank
hostz-frank / functions.php
Last active January 17, 2020 08:52
Sprachweiche im Child-Template
<?php
/**
* Angebot-Nachfrage-Buttons nach Sprache ausgeben.
*/
add_action( 'wp_footer', function() {
if( get_locale() == 'de_DE' ) { ?>
<a href="/angebote/" class="sticky-divi-button">Angebote</a>
<a href="/anfrage/" class="sticky-divi-button-2">Anfragen</a>
<?php } elseif( get_locale() == 'it' ) { ?>
<a href="/it/offerta/" class="sticky-divi-button">Offerta</a>
@hostz-frank
hostz-frank / functions.php
Last active October 17, 2019 10:35
DSGVO-Hinweis bei passwortgeschütztem Inhalt in WordPress
<?php
// Die folgenden Zeilen in die functions.php des aktiven Child-Themes kopieren.
add_filter( 'the_password_form', 'custom_password_form' );
function custom_password_form() {
global $post;
$label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
$o = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form" method="post">
<p class="pw-notice">Bitte beachten Sie, dass das Absenden eines Passworts ein <b>Cookie</b> in ihrem Browser setzt, das sich 10 Tage lang Ihren Zugang "merkt".<br></p>
<label class="pass-label" for="' . $label . '">Passwort: </label> <input name="post_password" id="' . $label . '" type="password" style="background: #ffffff; border:1px solid #999; color:#333333; pad$
@hostz-frank
hostz-frank / functions.php
Created April 9, 2019 10:24
Add another posttype to Divi's blog module listings
<?php
/**
* Copy the block below into your child theme's functions.php
*/
// Add another posttype to Divi's blog module listings.
add_action( 'pre_get_posts', 'divi_child_add_post_type_to_blog_module', 12 );
function divi_child_add_post_type_to_blog_module( $wp_query ) {
$slug = 'blog-module'; // ADJUST! => on which page to enable ...
$cpt = 'project'; // ADJUST! => desired additional post type
@hostz-frank
hostz-frank / .htaccess
Last active March 18, 2019 17:40
Efficient redirection for faster load times
# .htaccess
########################################################################
#### ONLY ONE OF THE NEXT TWO BLOCKS BELOW IS FOR YOU! Don't copy both!!
########################################################################
# Redirect to https://www - PLEASE ADJUST YOUR DOMAIN NAME (RewriteRule line)!
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on [OR]
@hostz-frank
hostz-frank / functions.php
Last active October 29, 2021 13:05
Send mail copy to users of Divi's contact form.
<?php
/**
* Send copy to Divi's contact form sender.
*/
add_filter( 'et_contact_page_headers', 'change_et_contact_page_headers', 10, 3 );
function change_et_contact_page_headers( $headers, $contact_name, $contact_email ) {
$headers[] = 'Cc: ' . $contact_email;
return implode( "\n", $headers );
}
@hostz-frank
hostz-frank / bloom-no-external-fonts.php
Created June 18, 2018 15:08
Bloom without Google Webfonts
<?php
/*
Plugin Name: Bloom without Google webfonts
Description: Remove Bloom fonts loaded from Google
Author: Frank
Version: 0.1
*/
defined( 'ABSPATH' ) || die();
@hostz-frank
hostz-frank / functions.php
Created May 22, 2018 20:49
Das Plugin "Cookie Notice" für WordPress ermöglicht Opt-In in Facebook-Pixel und Google Analytics ...
<?php
/**
* Cookie-abhängiger Tracking-Code: Google Analytics und Facebook-Pixel.
*
* Falls Autoptimze installiert ist, wird der JS-Code
* auch minimiert (empfohlen).
*
* ACHTUNG: FB-Pixel-ID "12345678901234" und Google-Analytics-ID "UA-xxxxxxxxxx"
* müssen unten im Code natürlich angepasst werden!!
*/
@hostz-frank
hostz-frank / functions.php
Created May 21, 2018 18:03
Impressum-Link neben Datenschutz-Link auf der wp-login.php
/**
* Impressum-Link zum Privacy Policy Link auf Login-Seite hinzufügen (wp-login.php).
*/
add_filter( 'the_privacy_policy_link', function( $link, $privacy_policy_url ) {
return $link . '&nbsp; | &nbsp;<a href="/impressum/">Impressum</a>';
}, 10, 2 );
@hostz-frank
hostz-frank / wp-config.php
Created May 11, 2018 17:10
Enable debugging in WP into file wp-content/debug.log
<?php
// paste directly above: "/* That's all, stop editing! Happy blogging. */"
define('WP_DEBUG', true );
if ( WP_DEBUG ) {
define( 'SAVEQUERIES', true );
define( 'SCRIPT_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
}
@hostz-frank
hostz-frank / functions.php
Last active March 13, 2018 11:05
Im Divi-Theme das Laden externer Google-Fonts abschalten. / Disable external pulled web fonts from Google for the Divi theme
<?php
// Copy the code below into your Divi child(!) theme's functions.php
/**
* Disable external font load from Google.
*
* Useful after putting Google fonts on your own server;
* see https://google-webfonts-helper.herokuapp.com/fonts
*/