Skip to content

Instantly share code, notes, and snippets.

View shackep's full-sized avatar

Peter Shackelford shackep

View GitHub Profile
@shackep
shackep / auto_featured_image_refactored.php
Last active September 2, 2016 19:13
Refactored Auto Featured Image.
@shackep
shackep / auto_featured_image.php
Last active September 2, 2016 12:31
Get first attached image in post content and set as featured image.
/**
* Create Content_TOC:
* 1) Setup default header elements
* 2) Register shortcode
*/
protected function __construct() {
// Register TOC shortcode
add_shortcode( 'hm_content_toc', array( $this, 'shortcode' ) );
// Shortcake UI plugin integration (Source: https://github.com/fusioneng/Shortcake)
if ( function_exists( 'shortcode_ui_register_for_shortcode' ) ) {
{# To make these available in your template, you will need to: {% import "/component_helpers.html" as helpers %} #}
{# Convert a date to a specific format: 19th April 2016 #}
{% macro date_formatted(givenDate) %}
{{ givenDate | date('jS F Y') }}
{% endmacro %}
{# Usage: {{ helpers.givenDate(post.date)}} #}
{# Use an svg associated background image #}
{% macro watermark(svg) %}
<a href="http://www.twitter.com/{{ twitter|trim('@') }}">{{ twitter }}</a>
<img alt="{{ image.alt }}"
srcset="
{{ image.src | resize(1600)}} 1600w,
{{ imgage.src | resize(1000)}} 1000w,
{{ imgage.src | resize(700)}} 700w
{{ imgage.src | resize(300)}} 300w
"
src="{{ image.src | resize(1000)}}"
sizes="100vw"
>
<a href="mailto:{{ email }}">{{ email }}</a>
<a href="{{ link }}">
{# Add Responsive Image #}
{% include 'components/image.html' %}
</a>
<div class="plain-panel">
<div>
<h3><a class="person-name" href="{{ link }}">{{ name }}</a></h3>
<p class="job-title">{{ title}}</p>
<ul>
<li>
@shackep
shackep / Sidebar with Author
Created June 10, 2016 15:02
Twig Basics Example 9
{# Single Author Context #}
{% block sidebar %}
{% include 'modules/author.twig' %}
{% endblock %}
{# Multiple Author Context #}
{% block sidebar %}
{% for author in authors %}
{% include 'modules/author.twig' %}
{% endfor %}
@shackep
shackep / layouts_sidebar-right.twig
Created June 10, 2016 14:59
Twig Basics Example 8
<div class="row">
<div class="columns medium-8 content">
{% block content %}{% endblock %}
</div>
<div class="columns medium-4 sidebar">
{% block sidebar %}{% endblock %}
</div>
<div class="clearfix"></div>
</div>