Skip to content

Instantly share code, notes, and snippets.

@hansspiess
hansspiess / prevent-text-breakouts.css
Created August 18, 2012 22:17
Frontend: Prevent huge user generated strings from breaking the layout
.prevent-text-breakouts {
-ms-word-break: break-all;
word-break: break-all;
word-break: break-word;
-webkit-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
}
@hansspiess
hansspiess / template-file.php
Created August 19, 2012 13:35
Wordpress: Redirect to first child page
<?php
$pagekids = get_pages( "child_of=".$post->ID."&sort_column=menu_order" );
if ( $pagekids ) {
$firstchild = $pagekids[0];
wp_redirect( get_permalink( $firstchild->ID ) );
}
?>
@hansspiess
hansspiess / assign-max-value-to-elements.js
Created November 15, 2012 14:33
Frontend: assign max or min Value to set of given elements
/* set equal height on boxes */
/* http://stackoverflow.com/questions/5052673/jquery-min-max-property-from-array-of-elements */
Array.max = function( array ){
return Math.max.apply( Math, array );
};
var heights = jQuery(".box").map(function() {
return jQuery(this).height();
}).get();
jQuery(".box").css("height", Array.max(heights));
@hansspiess
hansspiess / .htaccess
Created April 21, 2013 12:52
let test uri pass trough htaccess password protection
SetEnvIf Request_URI "/uri.php$" test_uri
Order Deny,Allow
AuthUserFile /path/to/.htpasswd
AuthName "Bitte Anmelden"
AuthType Basic
<Limit GET>
require valid-user
</Limit>
@hansspiess
hansspiess / template-contact.php
Created October 3, 2013 19:42
Wordpress: Simple Contact Form
<?php
/*
Template Name: Kontakt
*/
?>
<?php /* other template code goes here... */ ?>
<?php
@hansspiess
hansspiess / functions.php
Created October 4, 2013 10:13
Wordpress: Add Post Count with specific Age to Category Links
<?php
/* other function.php code goes here... */
function my_custom_walker( $args ) {
return array_merge( $args, array( 'walker' => new My_Custom_Walker() ) );
}
add_filter( 'wp_nav_menu_args', 'my_custom_walker' );
@hansspiess
hansspiess / index.html
Last active August 29, 2015 13:59
A Pen by Hans Spieß.
<div class="coindesk js-coindesk">
<p class="coindesk__price">
€ <span class="js-eur-value"></span>
</p>
<p>
Zuletzt aktualisiert am <span class="js-last-updated"></span>
</p>
<p class="small">Powered by <a href="/price/">CoinDesk</a></p>
</div>
@hansspiess
hansspiess / de-DE.override.ini
Last active November 20, 2018 07:01
Implement Icon Font with Joomla 2.5 pagination.php
;to be placed in ROOT/language/overrides/
JLIB_HTML_START="<i class=\"fa fa-fast-backward\"></i>"
JPREV="<i class=\"fa fa-backward\"></i>"
JNEXT="<i class=\"fa fa-forward\"></i>"
JLIB_HTML_END="<i class=\"fa fa-fast-forward\"></i>"