Skip to content

Commit

Permalink
Add arguments to kind_get_the_title
Browse files Browse the repository at this point in the history
  • Loading branch information
dshanske committed Dec 25, 2023
1 parent 2213267 commit 46d01a6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
18 changes: 12 additions & 6 deletions includes/kind-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,25 +136,31 @@ function kind_src_url_in_content( $content ) {
* Get a Marketed Up Link to the Post.
*
* @param WP_Post|null Post to Display.
* @param string|array Classes to add to link
* @param string|array Classes to add to the date
* @return string Marked up link to a post.
**/

function kind_get_the_link( $post = null, $cls = null ) {
function kind_get_the_link( $post = null, $cls = null, $date_cls = null ) {
$post = get_post( $post );
$kind = get_post_kind_slug( $post );

if ( is_array( $cls ) ) {
$cls = implode( ' ', $cls );
}
$cls = 'class=' . $cls;
$time_string = '<time %1$s datetime="%2$s">%3$s</time>';

if ( is_array( $date_cls ) ) {
$date_cls = implode( ' ', $date_cls );
}

$time_string = '<time class="%3$s" datetime="%1$s">%2$s</time>';
$time_string = sprintf(
$time_string,
esc_attr( $cls ),
esc_attr( get_the_date( DATE_W3C, $post ) ),
get_the_date( '', $post )
get_the_date( '', $post ),
$date_cls
);
return sprintf( '<a href="%2$s">%1$s</a> - %3$s', kind_get_the_title( $post, $kind ), get_the_permalink( $post ), $time_string );
return sprintf( '<a class="%4$s" href="%2$s">%1$s</a> - %3$s', kind_get_the_title( $post, $kind ), get_the_permalink( $post ), $time_string, esc_attr( $cls ) );
}


Expand Down
5 changes: 4 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Post Kinds #
**Contributors:** [dshanske](https://profiles.wordpress.org/dshanske)
**Tags:** indieweb, interaction, posts, webmention, share, like, scrobble
**Stable tag:** 3.7.1
**Stable tag:** 3.7.2
**Requires at least:** 4.9.9
**Requires PHP:** 7.0
**Tested up to:** 6.4
Expand Down Expand Up @@ -285,6 +285,9 @@ through future plugin updates.

## Changelog ##

### 3.7.2 ( 2023-12-25 ) ###
* Fix markup on kind_get_the_link function to allow for classes for date for overall link

### 3.7.1 ( 2023-12-17 ) ###
* Fix issue where the brackets for kind in the title were added even when there was no kind

Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
=== Post Kinds ===
Contributors: dshanske
Tags: indieweb, interaction, posts, webmention, share, like, scrobble
Stable tag: 3.7.1
Stable tag: 3.7.2
Requires at least: 4.9.9
Requires PHP: 7.0
Tested up to: 6.4
Expand Down Expand Up @@ -281,6 +281,9 @@ through future plugin updates.

== Changelog ==

= 3.7.2 ( 2023-12-25 ) =
* Fix markup on kind_get_the_link function to allow for classes for date for overall link

= 3.7.1 ( 2023-12-17 ) =
* Fix issue where the brackets for kind in the title were added even when there was no kind

Expand Down

0 comments on commit 46d01a6

Please sign in to comment.