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
Last active August 29, 2015 14:07
Load Parent Theme CSS in Child Theme without using @import
<?php
function twentytwelve_child_scripts() {
wp_deregister_style( 'twentytwelve-style' );
wp_register_style( 'twentytwelve-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'twentytwelve-child-style', get_stylesheet_uri(), array( 'twentytwelve-style' ) );
}
add_action( 'wp_enqueue_scripts', 'twentytwelve_child_scripts', 11 );
<?php
function tl_umlaut_repair( $content ) {
/*
* Why?
* For everyone getting this warning from W3C: "Text run is not in Unicode Normalization Form C."
* http://www.w3.org/International/docs/charmod-norm/#choice-of-normalization-form
*/
/*
@Zodiac1978
Zodiac1978 / functions.php
Created December 3, 2014 22:53
Remove "website" field from comment form
<?php
add_filter('comment_form_default_fields', 'url_filtered');
function url_filtered($fields)
{
if(isset($fields['url']))
unset($fields['url']);
return $fields;
}
@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 / threaded_comment_feed_enhancer.php
Last active December 29, 2015 16:39
Threaded Comment Feed Enhancer - Adds an info text in comment body from comment feed if it is a threaded comment
<?php
/**
* Plugin Name: Threaded Comment Feed Enhancer
* Plugin URI: http://torstenlandsiedel.de
* Text Domain: threaded-comment-feed-enhancer
* Domain Path: /languages
* Description: Enhances the threaded comments feed
* Version: 1.2.0
* Author: Torstenlandsiedel
* Author URI: http://torstenlandsiedel.de
@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');
<?php
function md_filter_curly_double_quotes( $translations, $text, $context, $domain ) {
if ( 'opening curly double quote' == $context && '&#8220;' == $text ) {
$translations = '&#8222;';
} else if ( 'closing curly double quote' == $context && '&#8221;' == $text ) {
$translations = '&#8220;';
}
return $translations;
@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';
}