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 | |
class First_Image_To_Thumbnail{ | |
public function __construct(){ | |
add_action('transition_post_status', array($this, 'autoset_featured'), 10, 3 ); | |
} | |
public function search_post_content_first_item( $tag, $post ){ | |
$dom = new DOMDocument(); | |
@$dom->loadHTML( $post->post_content ); | |
$search_dom = new DOMXPath($dom); |
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 autoset_featured( $new_status, $old_status, $post ) { | |
// Only run on manual saves of posts that are being published or have been published. | |
if ( $new_status != 'publish' || wp_is_post_autosave( $post->ID ) || $post->post_type != 'post' || empty( $post->post_content || has_post_thumbnail( $post->ID ) )) { | |
return; | |
} | |
// Is there already a thumbnail set? | |
$already_has_thumb = has_post_thumbnail( $post->ID ); | |
// Yes. Ok, we are done here | |
if($already_has_thumb){ |
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
/** | |
* 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' ) ) { |
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
{# 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) %} |
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
<a href="http://www.twitter.com/{{ twitter|trim('@') }}">{{ twitter }}</a> |
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
<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" | |
> |
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
<a href="mailto:{{ email }}">{{ email }}</a> |
NewerOlder