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_ad_after_2nd_paragraph.php
Created February 17, 2014 15:40
WordPress Snippet um Werbung, z.B. AdSense, nach dem zweiten Absatz eines Posts einzublenden. Source: http://www.wpbeginner.com/wp-tutorials/how-to-insert-ads-within-your-post-content-in-wordpress/
<?php
//Insert ads after second paragraph of single post content.
add_filter( 'the_content', 'prefix_insert_post_ads' );
function prefix_insert_post_ads( $content ) {
$ad_code = '<div>Ads code goes here</div>';
@stebrech
stebrech / wp_neue_bildformate_media_uploader.php
Created February 18, 2014 17:12
WordPress Snippet (für functions.php oder Plugin). Werden zu den Standardgrössen zusätzliche Bildformate definiert, werden diese nicht im Media-Uploader angezeigt. Blogartikel: http://www.pixelstrol.ch/blog/2014/02/wp-snippet-alle-bildgroessen-im-medien-uploader-anzeigen/ Quellen: http://wp-snippets.com/show-custom-image-sizes-in-admin-media-upl…
<?php
function show_image_sizes( $sizes ) {
$new_sizes = array();
$added_sizes = get_intermediate_image_sizes();
// $added_sizes is an indexed array, therefore need to convert it
// to associative array, using $value for $key and $value
foreach( $added_sizes as $key => $value) {
$new_sizes[$value] = $value;
@stebrech
stebrech / wp_excerpt_weiterlesen_link.php
Last active August 29, 2015 13:56
WordPress Snippet (für functions.php oder Plugin). Dieses Snippet fügt dem Auszug (Excerpt) in jedem Fall ein Weiterlesen-Link hinzu. Quelle: http://www.transformationpowertools.com/wordpress/read-more-on-all-excerpts-in-wordpress
@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);
@stebrech
stebrech / change_login_logo.php
Created November 30, 2012 14:32
Ersetze das WordPress Logo auf der Login-Seite mit deinem eigenem Logo.
function custom_login_logo() {
echo
'<style type="text/css">
h1 a {
background-image:url('.get_site_url().'/wp-content/uploads/login.png) !important;
background-size: 100% auto !important;
margin-left: 8px !important;
width: 312px !important;
}
</style>';