Skip to content

Instantly share code, notes, and snippets.

@hansspiess
hansspiess / horizontal-nav.css
Created March 21, 2012 09:47
Frontend: horizontal navigation list
#navigation {
border: 1px solid #222222;
background: #040505 url(../images/background-navigation.gif) repeat-x;
height: 1%;
overflow: hidden;
margin-bottom: 2px;
}
#navigation ul {
margin: 0;
@hansspiess
hansspiess / form-elements.html
Created March 21, 2012 09:53
Frontend: form elements
<input id="radio_id" type="radio" name="radio_name" value="radio_value" checked=""><label for="radio_id">Labeltext</label>
<select id="select_id" name="select_name" size="1">
<option>Text</option>
</select>
<input type="submit" value="Submit" class="" />
@hansspiess
hansspiess / hs_get_parent_post_thumbnail.php
Created August 4, 2012 23:17
Wordpress: Displaying Article Thumbnail of parent page on Child Page
<?php
global $post;
if ( is_page() ) {
/* Get an array of Ancestors and Parents if they exist */
$parents = get_post_ancestors( $post->ID );
/* Get the top Level page->ID count base 1, array base 0 so -1 */
@hansspiess
hansspiess / batch_import_sprites.sass
Created August 5, 2012 14:02
Frontend: batch import images as sprite with SASS
@import "my-icons/*.png";
@include all-my-icons-sprites;
@hansspiess
hansspiess / hs_mailreplace.php
Created August 5, 2012 14:21
Php: Mask email address in string, using preg_replace_callback
<?php
function hs_mailreplace($str) {
return preg_replace_callback ('^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})^',
create_function (
'$str',
'for ($i = 0; $i < strlen($str[0]); $i++) {
$result .= "&#" . ord(substr($str[0], $i, 1)) . ";";
};
@hansspiess
hansspiess / fiddle.css
Created August 8, 2012 20:38
Frontend: Sticky Footer
* {
margin: 0;
padding: 0;
}
html, body, #wrap {
height: 100%;
}
body > #wrap {
@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 / .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 / 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 / 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;
}
?>