Skip to content

Instantly share code, notes, and snippets.

View DWboutin's full-sized avatar
🎯
Focusing

Mike Boutin DWboutin

🎯
Focusing
  • Quebec city
View GitHub Profile
@DWboutin
DWboutin / functions.php
Created August 18, 2014 13:01
Get post thumbnail src
<?php
// usage: $imageSrc = get_the_post_thumbnail_src(get_the_post_thumbnail( $post->ID, 'medium'));
function get_the_post_thumbnail_src($img)
{
return (preg_match('~\bsrc="([^"]++)"~', $img, $matches)) ? $matches[1] : '';
}
?>
@DWboutin
DWboutin / functions.php
Created August 18, 2014 14:06
Woocommerce get regular and sale price
<?php
function the_product_price($product){
//get the sale price of the product whether it be simple, grouped or variable
$sale_price = '<span class="new">'.get_post_meta( get_the_ID(), '_price', true).'</span>';
//get the regular price of the product, but of a simple product
$regular_price = get_post_meta( get_the_ID(), '_regular_price', true);
//oh, the product is variable to $sale_price is empty? Lets get a variation price
@DWboutin
DWboutin / pageTemplate.php
Created August 18, 2014 14:48
Custom Order function WP_Query
<php
function orderby( $a, $b ) {
global $posts;
$apos = get_field('niveau_academique', $a->ID);
$bpos = get_field('niveau_academique', $b->ID);
return ( $apos < $bpos ) ? -1 : 1;
}
usort( $projets->posts, "orderby" );
@DWboutin
DWboutin / main.js
Created September 10, 2014 18:35
SVG PNG Fallback
if(!Modernizr.svg) {
$('img[src*="svg"]').attr('src', function() {
return $(this).attr('src').replace('.svg', '.png');
});
}
function reportError(error, message) {
message = message || '';
console.error(
'ERROR: ' + message + ' [' + error.toString() + ']\n' +
'\nName:\t\t' + (error.name || '-') +
'\nMessage:\t' + (error.message || '-') +
'\nFile:\t\t\t' + (error.fileName || '-') +
'\nSource:\t\t' + ((error.toSource && error.toSource()) || '-') +
'\nLine #:\t\t' + (error.lineNumber || '-') +
'\nColumn #:\t' + (error.columnNumber || '-') +
@DWboutin
DWboutin / node.js
Created November 10, 2014 14:22
Create custom event with Node.js
var events = require('events');
var emitter = new events.EventEmitter();
function taskStatus(status) {
if (status === 'done') {
emitter.emit('done');
} else if (status === 'doing') {
emitter.emit('doing');
}
}
@DWboutin
DWboutin / print.js
Created December 4, 2014 15:54
Javascript Print Cross-browser
if(navigator.userAgent.indexOf('MSIE')){
window.document.execCommand('print', false, null);
}else{
window.print();
}
@mixin font-face($family, $filename, $weight, $style)
@font-face
font-family: $family
src: url('../fonts/#{$filename}.eot')
src: url('../fonts/#{$filename}.eot?#iefix') format("embedded-opentype"), url('../fonts/#{$filename}.woff') format("woff"), url('../fonts/#{$filename}.ttf') format("truetype"), url('../fonts/#{$filename}.svg##{$filename}') format("svg")
font-style: $style
font-weight: $weight
@DWboutin
DWboutin / select.js
Created February 17, 2015 15:17
Select won't change on F5 fix
$('select').each(function(){
var select = $(this);
var html = select[0].outerHTML;
var val = $(html).children('option:selected').val();
select.val(val);
});
@DWboutin
DWboutin / placeholder.aspx
Last active August 29, 2015 14:15
SharePoint 2010 placeholders
<!-- Titre du site -->
<SharePoint:ProjectProperty Property="Title" runat="server"/>
<!-- Breadcrumb -->
<asp:SiteMapPath runat="server" id="SiteMapPath1" ParentLevelsDisplayed="1" PathSeparator="&nbsp;&gt;&nbsp;">
<CurrentNodeStyle CssClass="actual" />
</asp:SiteMapPath>