Skip to content

Instantly share code, notes, and snippets.

View yratof's full-sized avatar
🍊
Eating an orange

Andrew yratof

🍊
Eating an orange
View GitHub Profile
@yratof
yratof / balance.js
Created September 17, 2015 16:37
Balancing act: Getting your headings to even out when splitting into two or more lines
/* Pulled from this: https://github.com/adobe-webplatform/balance-text*/
!function(a,b){"use strict";var c=function(a,b,c){var d;return function(){function g(){c||a.apply(e,f),d=null}var e=this,f=arguments;d?clearTimeout(d):c&&a.apply(e,f),d=setTimeout(g,b||100)}};jQuery.fn[b]=function(a){return a?this.bind("resize",c(a)):this.trigger(b)}}(jQuery,"smartresize"),function(a){"use strict";function e(){this.reset()}var d,b=document.documentElement.style,c=b.textWrap||b.WebkitTextWrap||b.MozTextWrap||b.MsTextWrap||b.OTextWrap;e.prototype.reset=function(){this.index=0,this.width=0};var f=function(a,b){var e,c=/\s(?![^<]*>)/g;if(!d)for(d=[];null!==(e=c.exec(a));)d.push(e.index);return-1!==d.indexOf(b)},g=function(b){b.find('br[data-owner="balance-text"]').replaceWith(" ");var c=b.find('span[data-owner="balance-text"]');if(c.length>0){var d="";c.each(function(){d+=a(this).text(),a(this).remove()}),b.html(d)}},h=function(a){return b=a.get(0).currentStyle||window.getComputedStyle(a.get(0),null),"justify"===b.textAlign}
@yratof
yratof / download.sh
Created September 21, 2015 13:10
Download a website for Static use
wget -r -P / --user-agent="" -e robots=off --wait 1 -E http://website.com
@yratof
yratof / fire-safety-alias.sh
Last active May 11, 2016 11:51
Incase of fire
# Fire Escape // Add this alias incase theres a fire.
alias fire='git branch -b emergency-fire && git add -A && git commit -m "Theres a fire happening, so Im pushing everything I have so far incase the computers dont make it out alive!" && git push'
@yratof
yratof / woo-rating.scss
Created October 6, 2015 08:48
Woocommerce Star Rating SCSS
p.stars {
position: relative;
font-size: u(1.5rem);
margin: 0;
text-align: center;
width: 200px;
margin: 0 auto;
a {
@yratof
yratof / functions.php
Last active July 12, 2019 19:14
woocommerce mini cart
<?php
// Ensure cart contents update when products
// are added to the cart via AJAX
add_filter('add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment');
function woocommerce_header_add_to_cart_fragment( $fragments ) {
global $woocommerce;
ob_start();
echo '<a class="cart-contents" href="' . $woocommerce->cart->get_cart_url() .'" title="' . __( 'View your shopping cart', 'drivdigital' ) .'">';
echo sprintf( _n( '%d item', '%d items', $woocommerce->cart->cart_contents_count, 'drivdigital' ), $woocommerce->cart->cart_contents_count) . ' - ' . $woocommerce->cart->get_cart_total();
echo '</a>';
@yratof
yratof / scroll.js
Last active December 16, 2015 12:43
Scroll until hit a class / element
<script type="text/javascript">
jQuery(document).ready(function($){
$.fn.scrollBottom = function() {
return $(document).height() - this.scrollTop() - this.height();
};
$(window).scroll(function () {
// Pick the element you want to move
var offset = $('#parent').offset();
// This is the top of the view
@yratof
yratof / taxonomy.php
Last active April 29, 2016 23:24
List all taxonomies and loop their posts
<?php
/*
* Loop for taxonomies to show their posts
*/
$taxonomy = 'brand';
$terms = get_terms($taxonomy);
foreach ($terms as $term) {
$wpq = array (
@yratof
yratof / functions.php
Last active October 23, 2015 07:18
Function for getting the featured image URL
function get_thumbnail_url($size) {
$image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id, $size, true);
if (has_post_thumbnail()) { echo $image_url[0]; }
};
@yratof
yratof / functions.php
Created October 27, 2015 09:54
Displat advanced custom fields to Woocommerce Reviews
<?php
add_action( 'woocommerce_review_before_comment_meta', 'comment_title' );
function comment_title(){
$field = get_field('title', 'comment_' . get_comment_ID());
if($field){
echo '<h4>' . $field .'</h4>';
}
}
@yratof
yratof / acf.php
Created October 28, 2015 09:01
Image and Mobile image for Advanced custom fields 5 + wordpress mobile
<?php
$image = get_sub_field('background_image');
// Image related details
$img_title = $image['title'];
$alt = $image['alt'];
$size = 'hero-video';
$thumb = $image['sizes'][ $size ];
$width = $image['sizes'][ $size . '-width' ];