Skip to content

Commit

Permalink
only output markup if hook is used
Browse files Browse the repository at this point in the history
  • Loading branch information
billerickson committed Apr 11, 2019
1 parent b2dbdde commit 70ae7ed
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
11 changes: 11 additions & 0 deletions inc/helper-functions.php
Expand Up @@ -181,3 +181,14 @@ function ea_icon( $atts = array() ) {

return $svg;
}

/**
* Has Action
*
*/
function ea_has_action( $hook ) {
ob_start();
do_action( $hook );
$output = ob_get_clean();
return !empty( $output );
}
9 changes: 9 additions & 0 deletions inc/loop.php
Expand Up @@ -45,6 +45,15 @@ function ea_default_loop() {
}
add_action( 'tha_content_loop', 'ea_default_loop' );

/**
* Entry Title
*
*/
function ea_entry_title() {
echo '<h1 class="entry-title">' . get_the_title() . '</h1>';
}
add_action( 'tha_entry_top', 'ea_entry_title' );

/**
* Post Comments
*
Expand Down
9 changes: 5 additions & 4 deletions partials/content.php
Expand Up @@ -10,10 +10,11 @@

echo '<article class="' . join( ' ', get_post_class() ) . '">';

echo '<header class="entry-header">';
echo '<h1 class="entry-title">' . get_the_title() . '</h1>';
if( ea_has_action( 'tha_entry_top' ) ) {
echo '<header class="entry-header">';
tha_entry_top();
echo '</header>';
echo '</header>';
}

echo '<div class="entry-content">';
tha_entry_content_before();
Expand All @@ -28,7 +29,7 @@
tha_entry_content_after();
echo '</div>';

if( has_action( 'tha_entry_bottom' ) ) {
if( ea_has_action( 'tha_entry_bottom' ) ) {
echo '<footer class="entry-footer">';
tha_entry_bottom();
echo '</footer>';
Expand Down

0 comments on commit 70ae7ed

Please sign in to comment.