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
@Zodiac1978
Zodiac1978 / functions.php
Created July 17, 2015 16:38
Add language to multisite description
<?php
add_action('wp_before_admin_bar_render', 'add_language_to_blog_name');
function add_language_to_blog_name( $wp_admin_bar ) {
global $wp_admin_bar;
$wp_admin_bar->add_menu( array(
'id' => 'site-name',
'title' => get_bloginfo( 'name' ) . ' | ' . get_bloginfo( 'language' ),
@Zodiac1978
Zodiac1978 / genderize.php
Last active September 28, 2015 11:22
Overwrite single translations in WordPress
<?php
/*
Plugin Name: Gender all the things
Description: Gender all the things
Version: 1.0
Author: Torsten Landsiedel
Author URI: http://torstenlandsiedel.de
*/
@Zodiac1978
Zodiac1978 / functionality-plugin.php
Last active December 21, 2023 09:01
A functionality plugin template for custom code that could be used on different sites
<?php
/**
* Plugin Name: Functionality Plugin Template
* Description: Add custom tweaks and snippets in this custom plugin.
* Plugin URI: https://torstenlandsiedel.de
* Version: 1.0.0
* Author: Torsten Landsiedel
* Author URI: https://torstenlandsiedel.de
* Licence: GPL 2
* License URI: http://opensource.org/licenses/GPL-2.0
@Zodiac1978
Zodiac1978 / functions.php
Created January 27, 2016 10:32
Customize more jump link
<?php
/* Change jump link to post beginning */
/* http://codex.wordpress.org/Customizing_the_Read_More */
function change_more_jump_link($link) {
$link = str_replace('#more-', '#post-', $link);
return $link;
}
add_filter('the_content_more_link', 'change_more_jump_link');
@Zodiac1978
Zodiac1978 / version.php
Created February 12, 2016 17:06
Check for @Version line in doc block of theme (addition for Theme Check plugin)
<?php
class VersionCheck implements themecheck {
protected $error = array();
function tc_templatepath( $file ) {
$filename = ( preg_match( '/themes\/([a-z0-9-]*\/.*)/', $file, $out ) ) ? $out[1] : basename( $file );
return $filename;
}
@Zodiac1978
Zodiac1978 / functions.php
Created March 23, 2016 17:44
Add mobile bodyclass if user agent is showing a mobile/tablet-device (using wp_is-mobile)
<?php
// Add mobile bodyclass
function add_mobile_bodyclass( $classes ) {
if ( wp_is_mobile() ) {
// add 'class-name' to the $classes array if is mobile user agent
$classes[] = 'mobile';
}
@Zodiac1978
Zodiac1978 / functions.php
Created July 13, 2016 15:09
Filter für das WordPress Caching-Plugin Cachify: Steuerung der Cache-Generierung. cachify_skip_cache = true verhindert die Cache-Bildung für die aufgerufene Blogseite. Für PHP 5.3.
<?php
add_filter(
'cachify_skip_cache',
function() {
return (
in_category('fruit') ? true : false
);
}
);
@Zodiac1978
Zodiac1978 / functions.php
Last active July 13, 2016 15:23
WordPress-Snippet: Redakteuren erlauben, das Dashboard zu bearbeiten, also auch das Statify-Dashboard-Widget.
<?php
function add_theme_caps() {
$role = get_role('editor');
$role->add_cap('edit_dashboard');
}
add_action('admin_init', 'add_theme_caps');
@Zodiac1978
Zodiac1978 / functions.php
Last active March 28, 2018 23:22
Change the signature delimiter to the correct syntax 'dash dash space' for http://contactform7.com
<?php
// Contact Form 7 - change to correct signature delimiter
// See: https://en.wikipedia.org/wiki/Signature_block#Signatures_in_Usenet_postings
function custom_mail_components($wpcf7_data, $form = null) {
$wpcf7_data['body'] = str_replace('--', '-- ', $wpcf7_data['body'] );
return $wpcf7_data;
}
add_filter( 'wpcf7_mail_components', 'custom_mail_components');