Skip to content

Instantly share code, notes, and snippets.

@michaelwilhelmsen
michaelwilhelmsen / 100%-sidebar-height.css
Created May 7, 2014 07:51
Make Sidebar 100% Height of Container
.container {
overflow: hidden;
}
#sidebar {
margin-bottom: -5000px; /* any large number will do */
padding-bottom: 5000px;
}
@michaelwilhelmsen
michaelwilhelmsen / simplepie-fetch-image.php
Created May 9, 2014 11:00
Using the built in Simplepie library in Wordpress, this function fetches the first img of each post. Display it using: echo '<img src="' .get_first_image_url($item->get_content()). '"/>';
/**
* Gets RSS Image Item Link
*
* Place the following inside rss markup
* to display the the first image of that post:
* echo '<img src="' .get_first_image_url($item->get_content()). '"/>';
*
*/
function get_first_image_url($html) {
if (preg_match('/<img.+?src="(.+?)"/', $html, $matches)) {
@michaelwilhelmsen
michaelwilhelmsen / remove-tabs.php
Created May 14, 2014 08:15
Remove the tabs from single products
remove_action('woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10);
@michaelwilhelmsen
michaelwilhelmsen / remove-product-category-from-shop.php
Created May 16, 2014 12:13
Hide products that are packages or subscription which belong to a page or has its own page by adding this into functions.php
add_action( 'pre_get_posts', 'custom_pre_get_posts_query' );
function custom_pre_get_posts_query( $q ) {
if ( ! $q->is_main_query() ) return;
if ( ! $q->is_post_type_archive() ) return;
if ( ! is_admin() ) {
$q->set( 'tax_query', array(array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array( 'PUT YOUR CATEGORY HERE' ), // Don't display products in the membership category on the shop page . For multiple category , separate it with comma.
'operator' => 'NOT IN'
@michaelwilhelmsen
michaelwilhelmsen / slide-up-and-down.css
Created May 16, 2014 19:22
Slide up and slide down transition effect
/* slider in open state */
.slider {
overflow-y: hidden;
max-height: 500px; /* approximate max height */
transition-property: all;
transition-duration: .5s;
transition-timing-function: cubic-bezier(0, 1, 0.5, 1);
}
@michaelwilhelmsen
michaelwilhelmsen / perfect-square-hack.css
Created June 2, 2014 15:06
Create perfect squares with css. Second solution uses viewport, but is only supported with IE9+
#square {
width: 100%;
height: 0;
padding-bottom: 100%;
}
@michaelwilhelmsen
michaelwilhelmsen / center.css
Created June 17, 2014 22:06
Use this to center element in window.
.center-me {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
@michaelwilhelmsen
michaelwilhelmsen / dynamic-shadows.css
Created July 11, 2014 10:58
Dynamic Shadow for images with transparency using filters
.png-image {
-webkit-filter: drop-shadow(12px 12px 25px rgba(0,0,0,0.5));
filter: url(#drop-shadow);
-ms-filter: "progid:DXImageTransform.Microsoft.Dropshadow(OffX=12, OffY=12, Color='#444')";
filter: "progid:DXImageTransform.Microsoft.Dropshadow(OffX=12, OffY=12, Color='#444')";
}
@michaelwilhelmsen
michaelwilhelmsen / remove-query-strings.php
Created September 11, 2014 12:56
Remove Query Strings to Optimize Page Speed. Put in functions.php
// Remove Query Strings to Optimize Page Speed
function _remove_query_strings_1( $src ){
$rqs = explode( '?ver', $src );
return $rqs[0];
}
function _remove_query_strings_2( $src ){
$rqs = explode( '&ver', $src );
return $rqs[0];
}
add_filter( 'script_loader_src', '_remove_query_strings_1', 15, 1 );
@michaelwilhelmsen
michaelwilhelmsen / zip.php
Created March 31, 2015 13:37
Whole Zip file with all relevant functions
<?php
/*
Plugin Name: Custom Functions for Screenpartners Bildebank
*/
/******************************************************
* TASK: Create LOW RES duplicates of uploaded images, *
* create alternate download button for these files *
* "Download Files" / "Download Low Res Files" *
******************************************************/