Skip to content

Instantly share code, notes, and snippets.

@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 / .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 / 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 / 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 / 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 / functions.php
Created August 17, 2012 14:28
Wordpress: Add custom Class to Contact Form 7 <form> tag
<?php
add_filter( 'wpcf7_form_class_attr', 'custom_custom_form_class_attr' );
function custom_custom_form_class_attr( $class ) {
$class .= ' nice';
return $class;
}
?>
@hansspiess
hansspiess / replace-text-with-image.css
Created August 10, 2012 19:53
Frontend: Replace Text with image, No-Images-Fallback
h1 {
background: url(image.gif);
height: 25px;
text-indent: -999em;
width: 250px;
overflow: hidden;
}
@hansspiess
hansspiess / .htaccess
Created August 10, 2012 19:47
.htaccess: Localhost / Live Server Switch
RewriteBase /
# Copy HTTP Authorization header value to HTTP_AUTOHRIZATION server variable for use by script
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# On live server, rewrite requests for URL-paths which do not resolve to specific
# physically-existing filetypes to my script, excluding the script's URL-path itself.
RewriteCond %{HTTP_HOST} !^localhost$
RewriteCond $1 !^index\.php
RewriteCond %{REQUEST_FILENAME} !-f
@hansspiess
hansspiess / function_call_from_template_file.php
Created August 10, 2012 10:15
Wordpress: Custom menu with description
<?php
wp_nav_menu( array(
'theme_location' => 'homepage_navigation_left',
'container' => FALSE,
'echo' => true,
'before' => '',
'after' => '',
'link_before' => '',
'link_after' => '',
@hansspiess
hansspiess / fiddle.css
Created August 8, 2012 20:38
Frontend: Sticky Footer
* {
margin: 0;
padding: 0;
}
html, body, #wrap {
height: 100%;
}
body > #wrap {