Skip to content

Instantly share code, notes, and snippets.

View oliwa's full-sized avatar

Oliver Hulisz oliwa

View GitHub Profile
@AdamTReineke
AdamTReineke / gist:1095961
Created July 20, 2011 21:18
Sort all definition lists (DL) on a page alphabetically
// jQuery code to sort all definition lists on a page alphabetically, assuming terms and definitions alternate. Place in $(document).ready(function(){ });
$("dl").each(function() {
$(this).children("dt").sort(function(a, b){
return a.innerHTML.toUpperCase() > b.innerHTML.toUpperCase() ? 1 : -1;
}).each(function() {
var dd = $(this).next("dd");
$(this).appendTo($(this).parent());
dd.appendTo(dd.parent());
})
@bohman
bohman / viewport.js
Last active March 15, 2025 07:05
jQuery get viewport size
// -----------
// Debugger that shows view port size. Helps when making responsive designs.
// -----------
function showViewPortSize(display) {
if(display) {
var height = jQuery(window).height();
var width = jQuery(window).width();
jQuery('body').prepend('<div id="viewportsize" style="z-index:9999;position:fixed;top:40px;left:5px;color:#fff;background:#000;padding:10px">Height: '+height+'<br>Width: '+width+'</div>');
jQuery(window).resize(function() {
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@jakebresnehan
jakebresnehan / Simple-HTML5-Local-Storage.js
Created March 6, 2012 06:02
Simple HTML5 Local Storage example to hide a element
Need to include Modernizer (http://www.modernizr.com/) and jQuery (http://jquery.com/)
$(document).ready(function($){
if (Modernizr.localstorage) {
$('#hide-button').click(function(e){
localStorage.setItem('subscribed',true);
$('#sign-up-form,#hide-button').hide();
$('#hide-button').hide();
@luetkemj
luetkemj / wp-query-ref.php
Last active April 6, 2025 09:15
WP: Query $args
// This gist is now maintained on github at https://github.com/luetkemj/wp-query-ref
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.github.io
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/4.9.4/src/wp-includes/query.php
*/
@aklump
aklump / jquery.equal_heights.js
Last active October 11, 2018 14:35
jQuery plugin to apply equal heights to children of a DOM element, with filters and targets.
/**
* Equal Heights Plugin
* Equalize the heights of all child elements to the tallest child
*
* @param object options
* - filter: An optional selector string to filter which children are considered.
* - not: An optional selector string to filter which children are NOT considered.
* - target: Additional selector of targets where height will be applied; these nodes
will not be used to calculate height, but will ONLY receive the calculated
height.
function shadeColor($color, $percent) {
$num = base_convert(substr($color, 1), 16, 10);
$amt = round(2.55 * $percent);
$r = ($num >> 16) + $amt;
$b = ($num >> 8 & 0x00ff) + $amt;
$g = ($num & 0x0000ff) + $amt;
return '#'.substr(base_convert(0x1000000 + ($r<255?$r<1?0:$r:255)*0x10000 + ($b<255?$b<1?0:$b:255)*0x100 + ($g<255?$g<1?0:$g:255), 10, 16), 1);
}
@levymetal
levymetal / direct_parent.php
Last active November 27, 2023 04:17
Custom Wordpress function which uses a nav walker to display a list of child pages from a common parent, which can be called from either the parent page (displays children) or any of the child pages (displays siblings). Detailed instructions available on my blog post here: http://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-…
<?php
wp_nav_menu( array(
'menu' => 'Menu Name',
'sub_menu' => true,
'direct_parent' => true
) );
@lunaroja
lunaroja / get_terms_chekboxes.php
Last active November 25, 2018 19:04
Wordpress: Get taxonomy terms as checkboxes with labels
<?php
function get_terms_chekboxes($taxonomies, $args) {
$terms = get_terms($taxonomies, $args);
foreach($terms as $term){
$output .= '<label for="'.$term->slug.'"><input type="checkbox" id="'.$term->slug.'" name="'.$term->taxonomy.'" value="'.$term->slug.'"> '.$term->name.'</label>';
}
return $output;
}
@alana-mullen
alana-mullen / Detect the last post in the WordPress loop
Last active May 29, 2023 16:50
Detect the last post in the WordPress loop
<?php if (($wp_query->current_post +1) == ($wp_query->post_count)) {
echo 'This is the last post';
} ?>
<?php if (($wp_query->current_post +1) != ($wp_query->post_count)) {
echo 'This is the not the last post';
} ?>