Skip to content

Instantly share code, notes, and snippets.

View jhned's full-sized avatar

Josh Nederveld jhned

View GitHub Profile
<div class="parent">
<div class="generic-child-element">
</div>
<div class="unique-child-element">
<h3 class="title">This Block's Title</h3>
</div>
<div class="another-child-element">
Some text…
</div>
<div class="module">
<div class="image">
<img src="a-cool-cucumber.gif" />
</div>
<div class="text">
<h3 class="title">This Block's Title</h3>
</div>
</div>
div.module {
.image {
margin: .5em;
}
img {
border: none;
}
.text {
padding: .25em;
add_filter('intermediate_image_sizes_advanced', function($sizes) {
unset( $sizes['thumbnail']);
unset( $sizes['medium']);
unset( $sizes['large']);
return $sizes;
});
@jhned
jhned / flexible-font-sizes-mixin.scss
Created April 19, 2016 21:19
Flexible font sizes
@function strip-unit($value) {
@return $value / ($value * 0 + 1);
}
@mixin flexible_font_sizes( $min-font-size, $max-font-size, $min-width, $max-width ) {
$font-size-difference: strip-unit($max-font-size - $min-font-size);
$viewport-difference: strip-unit($max-width - $min-width);
@media screen and #{breakpoint($min-width)} and #{breakpoint($max-width down)} {
@jhned
jhned / messy-code.php
Last active June 14, 2016 17:47
Many conditionals make a muckle
<?php
if (is_archive() || is_search()) :
$url = get_permalink();
if (has_post_thumbnail()) :
print '<a href="'.$url.'">';
the_post_thumbnail('thumbnail');
print '</a>';
endif;
if ( $post->post_type == 'post' ) print '<div itemprop="blogPost">';
@jhned
jhned / layouts-interior.php
Last active June 15, 2016 13:26
Header-int call
<?php
add_action( 'after_header', 'namespace_get_header_int', 20 );
function namespace_get_header_int() {
if ( !is_front_page() ) {
get_header('int');
}
}
@jhned
jhned / interior-clean.php
Last active March 5, 2017 21:00
How to do layout files
<?php
namespace CLIENT;
class Interior {
public static function init() {
add_action( 'wp', function () {
if ( ! is_front_page() ) {
self::hook_wordpress();
@jhned
jhned / is_news_or_post.php
Last active March 5, 2017 21:31
Cross post-type check
<?php
/**
* is_news_or_post
*
* A custom boolean check for Hexadite so that we can test if we're on a news or post layout without repeating every single check every time we need to.
*
* @return bool
*/
function is_news_or_post() {
@jhned
jhned / gist:fcba58b1434d647663dc168ac33488bc
Created September 21, 2016 14:44
check options AND defaults!
$fpt_options = array();
if ( array_key_exists( $pt_key, $options )
&& is_array( $options[ $pt_key ] )
&& array_key_exists( $post_type, $defaults[ $pt_key ] )
&& is_array( $options[ $pt_key ][ $post_type ] )
) {
$fpt_options = $options[ $pt_key ][ $post_type ];
}