This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin media-breakpoint($point) { | |
// &{ @content; } doesn't mean anything in the compiled output, | |
// but will workaround a SASS compiler issue that doesn't let | |
// us use %placeholders inside nested media queries. | |
@if $point == 'tablet-up' { | |
@media screen and (min-width: 48em) { &{ @content; } } | |
} | |
@else if $point == 'desktop-up' { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_page_template_name() { | |
global $wp_query; | |
$template_name = get_post_meta( $wp_query->post->ID, '_wp_page_template', true ); | |
return str_replace('.php','',$template_name); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unicodecsv | |
from django.http import HttpResponse | |
def export_as_csv_action(description="Export selected objects as CSV file", | |
fields=None, exclude=None, header=True): | |
""" | |
This function returns an export csv action | |
'fields' and 'exclude' work like in django ModelForm | |
'header' is whether or not to output the column names as the first row | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function humanize($array) { | |
while(count($array) > 0) { | |
$output .= array_pop($array); | |
if(count($array) > 1) { | |
$output .= ', '; | |
} elseif(count($array) > 0) { | |
$output .= ' and '; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import template | |
from django.template.defaultfilters import stringfilter | |
register = template.Library() | |
@register.filter | |
@stringfilter | |
def replace(value, arg): | |
args = arg.split(',') | |
return value.replace(args[0], args[1]) |