Skip to content

Commit

Permalink
Issue #23 create the metadates template part. Issue #24 with a [post-…
Browse files Browse the repository at this point in the history
…edit] shortcode temporary solution
  • Loading branch information
bobbingwide committed Nov 9, 2020
1 parent 7a79e13 commit a3c37c8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
4 changes: 3 additions & 1 deletion block-template-parts/home-query.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
<!-- wp:column {"width":"66.66%"} -->
<div class="wp-block-column" style="flex-basis:66.66%"><!-- wp:post-date {"format":"F j, Y"} /-->

<!-- wp:post-date {"format":"F j, Y"} /-->
<!-- wp:shortcode -->
[bw_fields post_modified]
<!-- /wp:shortcode -->

<!-- wp:post-hierarchical-terms {"term":"category"} /--></div>
<!-- /wp:column --></div>
Expand Down
2 changes: 2 additions & 0 deletions block-templates/single-oik-plugins.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

<!-- wp:template-part {"slug":"page-content","theme":"fizzie"} /-->

<!-- wp:template-part {"slug":"metadates", "theme":"fizzie", "className": "metadates" } /-->

<!-- wp:template-part {"slug":"information","theme":"fizzie", "className": "information"} /-->

<!-- wp:template-part {"slug":"download","theme":"fizzie", "className": "download"} /-->
Expand Down
2 changes: 2 additions & 0 deletions block-templates/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

<!-- wp:template-part {"slug":"post-content","theme":"fizzie"} /-->

<!-- wp:template-part {"slug":"metadates", "theme":"fizzie", "className": "metadates" } /-->

<!-- wp:template-part {"slug":"information","theme":"fizzie", "className": "information"} /-->

<!-- wp:template-part {"slug":"search","theme":"fizzie"} /-->
Expand Down
26 changes: 25 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ function fizzie_after_setup_theme()
*/
function fizzie_init() {
do_action( "oik_add_shortcodes" );
add_shortcode( 'archive_description', 'fizzie_archive_description');
add_shortcode( 'archive_description', 'fizzie_archive_description' );
add_shortcode( 'post-edit', 'fizzie_post_edit' );
}

function fizzie_enqueue_styles() {
Expand Down Expand Up @@ -154,6 +155,29 @@ function fizzie_archive_description( $attrs, $content, $tag ) {
return $html;
}

/**
* 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 fizzie_post_edit( $attrs, $content, $tag ) {
$link = '';
$url = get_edit_post_link();
if ( $url ) {
$class = 'bw_edit';
$text= __( '[Edit]', 'fizzie' );
$link='<a class="' . esc_attr( $class ) . '" href="' . esc_url( $url ) . '">' . $text . '</a>';
}
return $link;
}

/**
* Hook into register_block_types_args before WP_Block_Supports
*/
Expand Down

0 comments on commit a3c37c8

Please sign in to comment.