Skip to content

Instantly share code, notes, and snippets.

View stebrech's full-sized avatar

Stefan Brechbühl stebrech

View GitHub Profile
@stebrech
stebrech / wp_excerpt_laenge.php
Last active July 17, 2020 15:35
WordPress Snippet (für functions.php oder Plugin). Definiere die maximale Anzahl Wörter welche im Auszug (Excerpt) angezeigt werden sollen.
<?php
function custom_excerpt_length( $length ) {
return 20;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
?>
@stebrech
stebrech / wp_excerpt_more_string.php
Created February 23, 2014 10:49
WordPress Snippet (für functions.php oder Plugin). Ändere den more String im Auszug (Excerpt).
<?php
function new_excerpt_more( $more ) {
return '...';
}
add_filter('excerpt_more', 'new_excerpt_more');
?>
@stebrech
stebrech / albinomouse_alt_header.php
Last active August 29, 2015 13:59
An alternative header.php for the WordPress Theme AlbinoMouse v2.1.1. It puts the secondary navigation into the toggle menu on mobile devices.
<?php
/**
* The Header for AlbinoMouse.
* @package AlbinoMouse
*/
?>
<!DOCTYPE html>
<?php $options = get_option( 'albinomouse' ); ?>
<html <?php language_attributes(); ?>>
<?php
// Standard Size Thumbnail
if(false === get_option("thumbnail_crop")) {
add_option("thumbnail_crop", "1"); }
else {
update_option("thumbnail_crop", "1");
}
// Medium Size Thumbnail
if(false === get_option("medium_crop")) {
<?php
function url_spamcheck( $approved , $commentdata ) {
return ( strlen( $commentdata['comment_author_url'] ) > 50 ) ? 'spam' : $approved;
}
add_filter( 'pre_comment_approved', 'url_spamcheck', 99, 2 );
?>
<?php
remove_action( 'wp_head', 'rsd_link' );
remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'wp_generator' );
remove_action( 'wp_head', 'start_post_rel_link' );
remove_action( 'wp_head', 'index_rel_link' );
remove_action( 'wp_head', 'adjacent_posts_rel_link' );
remove_action( 'wp_head', 'wp_shortlink_wp_head' );
?>
/*
* Files Editoren abschalten
*/
define('DISALLOW_FILE_EDIT',true);
<?php
function penguin_content_image_sizes_attr($size) {
// Singular posts with sidebar
if ( is_singular() ) {
return '(max-width: 599px) calc(100vw - 50px), (max-width: 767px) calc(100vw - 70px), (max-width: 991px) 429px, (max-width: 1199px) 597px, 747px';
}
// Page full width without sidebar
if ( get_page_template_slug() === 'page-fullwidth.php' ) {
return '(max-width: 599px) calc(100vw - 50px), (max-width: 767px) calc(100vw - 70px), (max-width: 991px) 679px, (max-width: 1199px) 839px, 1039px';
}
<?php
function penguin_post_thumbnail_sizes_attr( $attr, $attachment, $size ) {
if ( 'Penguin800X400' === $size ) {
$attr['sizes'] = '(max-width: 767px) calc(100vw - 30px), (max-width: 991px) 469px, (max-width: 1199px) 696.5px, 414px';
}
if ( 'Penguin800X400' === $size && ( is_sticky() ) ) {
$attr['sizes'] = '(max-width: 767px) calc(100vw - 30px), (max-width: 991px) 469px, (max-width: 1199px) 696.5px, 846.5px';
}
if ( 'full' === $size && ( is_singular() ) ) {
$attr['sizes'] = '100vw';
@stebrech
stebrech / grepsuche-zahlen-gliedern.md
Last active November 3, 2017 12:07
GREP-Suche in InDesign: Zahlen mit Achtelgeviert-Leerzeichen gliedern und nicht mit einem Apostroph oder sonstigem.

Damit längere Zahlen besser gelesen werden können, werden diese in Tausenderschritten mit einem Leerzeichen (Achtelgeviert) gegliedert. In normalen Fliesstext wird erst ab fünfstelligen Ziffern gegliedert.

Suchen:

(?<=\d)\d(?=\d{3}\b)|\d(?=(\d{3}){2, }\b)

Ersetzen:

$0~&lt;