Skip to content

Instantly share code, notes, and snippets.

View daltonrooney's full-sized avatar

Dalton Rooney daltonrooney

View GitHub Profile
@daltonrooney
daltonrooney / gist:1784053
Created February 9, 2012 22:55
Resize vertical images max-height based on width of parent container for responsive layouts
function adaptiveResize() {
var $w, $target;
$target = $('img');
$target.each(function() {
$w = $(this).parent().width();
$target.css('max-height', $w );
});
}
@daltonrooney
daltonrooney / file-upload-handler.php
Created February 4, 2012 13:29
Multi-file WordPress uploads from the front-end
<?php /* This function attaches the image to the post in the database, add it to functions.php */
function insert_attachment($file_handler,$post_id,$setthumb='false') {
// check to make sure its a successful upload
if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false();
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
@daltonrooney
daltonrooney / gist:1737771
Created February 4, 2012 13:08
WordPress function - redirect all non-logged-in users to the login page.
<?php
/* Redirect all non-logged-in users to the login page (private site). Add to functions.php. */
function admin_redirect() {
if ( !is_user_logged_in()) {
wp_redirect( home_url('/wp-admin/') );
exit;
}
}
@daltonrooney
daltonrooney / gist:1683831
Created January 26, 2012 17:08
Custom menus for Xsilva Lightspeed
<?php function print_childs($categ, $catid){
$childs = $categ->categ_childs;
if( !$childs || ( count( $childs ) == 0 ) ){
return;
}
foreach($childs as $category){
@daltonrooney
daltonrooney / gist:1676097
Created January 25, 2012 12:44
PSP 1.5.4 custom js
/*!
* touchSwipe - jQuery Plugin
* http://plugins.jquery.com/project/touchSwipe
* http://labs.skinkers.com/touchSwipe/
*
* Copyright (c) 2010 Matt Bryson (www.skinkers.com)
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* $version: 1.2.3
*/
@daltonrooney
daltonrooney / gist:1623195
Created January 16, 2012 21:46
PSP 1.5.4 custom js
/*!
* touchSwipe - jQuery Plugin
* http://plugins.jquery.com/project/touchSwipe
* http://labs.skinkers.com/touchSwipe/
*
* Copyright (c) 2010 Matt Bryson (www.skinkers.com)
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* $version: 1.2.3
*/
@daltonrooney
daltonrooney / gist:1441149
Created December 7, 2011 02:27
Simple template for embedded slideshows
<?php
/*
/* Template Name: Gallery slideshow
/*
*/
?>
<?php get_header();?>
@daltonrooney
daltonrooney / gist:1377486
Created November 18, 2011 19:23
Proper way to load WordPress scripts (should be in functions.php)
<?php
function xx_load_scripts() {
wp_enqueue_script( 'jquery' );
wp_register_script( 'cycle', plugins_url( 'js/jquery.cycle.all.min.js', dirname(__FILE__) ), false, '2.99', true );
wp_enqueue_script( 'cycle' );
}
add_action('wp_enqueue_scripts', 'xx_load_scripts');
?>
@daltonrooney
daltonrooney / gist:1356238
Created November 10, 2011 21:10
Haiku custom
$('.player-container').css('visibility', 'visible').show();
/*Text Version*/
$("div[id^=haiku-text-player]").each(function() {
var num = this.id.match(/haiku-text-player(\d+)/)[1];
var ctrlId = "div#text-player-container" + num + " ul#player-buttons" + num;
var audioFile = $(ctrlId + " li.play a").attr("href");
$(this).jPlayer({
@daltonrooney
daltonrooney / gist:1153929
Created August 18, 2011 12:05
Portfolio Slideshow 1.2.1 alt stylesheet
.portfolio-slideshow {
z-index: 0 !important
}
div.slideshow-wrapper {
visibility: hidden;
margin:0 0 10px 0;
}
/* clearfix */