Skip to content

Commit

Permalink
Issue #1 - Add Published, Last Updated and (Edit) link to hero post
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbingwide committed Mar 27, 2021
1 parent 2f1e2e7 commit c80f175
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions block-template-parts/home-body.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<!-- /wp:separator -->

<!-- wp:post-date /-->
<p>Published: [bw_field post_date] | Last updated: [bw_field post_modified] [post-edit]</p>
<!-- /wp:query-loop -->
<!-- /wp:query -->

Expand Down
26 changes: 25 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function sb_init() {
// oik shortcodes won't be expanded.
}
//add_shortcode( 'archive_description', 'fizzie_archive_description' );
//add_shortcode( 'post-edit', 'fizzie_post_edit' );
add_shortcode( 'post-edit', 'sb_post_edit' );
}

add_action( 'init', 'sb_init', 20);
Expand Down Expand Up @@ -132,3 +132,27 @@ function genesis_sb_the_posts( $posts, $query ) {

add_filter( 'the_posts', 'genesis_sb_the_posts', 10, 2 );

/**
* Implements [post-edit] shortcode.
*
* If the user is authorised return a post edit link for the current post.
*
* @param $attrs
* @param $content
* @param $tag
*
* @return string
*/

function sb_post_edit( $attrs, $content, $tag ) {
$link = '';
$url = get_edit_post_link();
if ( $url ) {
$class = 'bw_edit';
$text= __( '[Edit]', 'sb' );
$link='<a class="' . esc_attr( $class ) . '" href="' . esc_url( $url ) . '">' . $text . '</a>';
}
return $link;
}


0 comments on commit c80f175

Please sign in to comment.