Skip to content

Instantly share code, notes, and snippets.

View Barrytron1983's full-sized avatar

B-Tron Barrytron1983

View GitHub Profile
@Barrytron1983
Barrytron1983 / gist:a9d79c1cdd86ad941026
Created October 28, 2014 18:06
Add a store location dropdown in the address area and output to email WOOCOMMERCE
/* testo2 */
// Hook in
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields2' );
// Our hooked in function - $fields is passed via the filter!
function custom_override_checkout_fields2( $fields ) {
$fields['billing']['Location'] = array(
'label' => __('If picking up your order locally, what is the most convenient store location for you?', 'woocommerce'),
'type' => 'select',
'class' => array('form-row-wide'),
@Barrytron1983
Barrytron1983 / gist:34eae8a6a09c2baa7048
Created September 10, 2014 10:28
Smoothscrolling for all page jumps
Use this baddass script CALLED AFTER JQUERY to make all pagejumps smooth as hot silk on a tight arse
Doesn't work wif you're using Bootstrap reveal/accordian thing. Well it works, but it kills that functionality
<script>
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
@Barrytron1983
Barrytron1983 / gist:a206a460ba4e2699996a
Created August 19, 2014 10:45
Add listing of future-scheduled Worpdress posts, with fallback text for none available
<div id="yourdivid">
<div id="yourdivid_header"><p>Kommende News</p></div>
<?php query_posts('showposts=10&post_status=future'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div >
<p class><b><?php the_title(); ?></b><?php edit_post_link('e',' (',')'); ?><br />
<span class="datetime"><?php the_time('j. F Y'); ?></span></p>
</div>
<?php endwhile; else: ?><p>No posts available</p><?php endif; ?>
</div>
@Barrytron1983
Barrytron1983 / gist:78490c8338a5925c02f3
Created August 12, 2014 15:38
Panel of right-sided staff pics with info appearing as each pic is selected inside a left-sided containing div (jscript & wordpress)
on page body:
<div id="purpsq" style="min-height: 220px">
<div id="imgDescription1" class="afterbox"><h4 style="color: #252525">Bill Smith</h4><hr><p class="frontbox_text">Bill joined us in 2004 and has etc etc and so on blah and lorem ipsum. He comes with fully functional punching arm action and accessories.</p></div>
<div id="imgDescription2" class="afterbox"><h4 style="color: #252525">Hugh Jass</h4><hr><p class="frontbox_text">Bill joined us in 2004 and has etc etc and so on blah and lorem ipsum. He comes with fully functional punching arm action and accessories.</p></div>
<div id="imgDescription3" class="afterbox"><h4 style="color: #252525">Rick O'Shea</h4><hr><p class="frontbox_text">Bill joined us in 2004 and has etc etc and so on blah and lorem ipsum. He comes with fully functional punching arm action and accessories.</p></div>
<div id="imgDescription4" class="afterbox"><h4 style="color: #252525">Annette Curtin</h4><hr><p class="frontbox_text">Bill joined us in 2004 and has etc etc and so on blah and
@Barrytron1983
Barrytron1983 / gist:42e265bc19f5364a101e
Created August 12, 2014 14:36
Fade in a load of elements sequentially on view (inview.js & wordpress)
//in Header:
<script src="<?php bloginfo('template_directory');?>/js/jquery.inview.min.js"></script>
//(also need JQuery 1.4 or above)
//where fds is a containing div and li items are the ones to be faded in....:
<script>
$(function() {
@Barrytron1983
Barrytron1983 / gist:83a7af950ba39818df7e
Created August 8, 2014 10:17
Jquery cycle fader for logo sliders, etc. Repeating fade through list of images in a holder
/* simple fader, handy for logo sliders etc. Light */
/* header */
<script src="<?php echo get_site_url(); ?>/wp-content/themes/Yourtheme/js/jquery.cycle.lite.js"></script>
<script>
$(document).ready(function() {
$('.fader_pics, .fader_pics1').cycle({
@Barrytron1983
Barrytron1983 / gist:48b553ddbd85e6aeae59
Created August 8, 2014 10:15
Change element based on IP location :: Wordpress/JS
/* Header */
<script>
jQuery.getJSON('http://freegeoip.net/json/', function(location) {
if (location.country_code == 'GB') {
jQuery("#change_number").text("GB Tel: +44 2307055");
}
});
</script>
@Barrytron1983
Barrytron1983 / gist:468dbcbb39ac3084bf2e
Created August 8, 2014 10:13
Revolution Slider outside buttons - controls slides outside of slider :: Wordpress/Revolution Slider
/* Header script - ('revapi3' being the id of the slider) */
<!-- Slider points linking to slides -->
<script type="text/javascript">
var revapi3;
jQuery(document).ready(function() {
@Barrytron1983
Barrytron1983 / gist:ebd7bf15bef884231214
Created August 8, 2014 10:05
Automatically fill a form field with text from another field using checkbox :: JS/Wordpress/Contact Form 7
/* Header: */
<script type="text/javascript">
function FillBilling(f) {
if(f.billingtoo.checked == true) {
f.invoice_textarea.value = f.deliveryaddress.value;
}
}
</script>
/* in the form - using Contact Form 7 */