fixed tests
This commit is contained in:
parent
8e87800ee0
commit
bdd9bd8775
2 changed files with 6 additions and 6 deletions
|
@ -31,7 +31,7 @@ class Hashtag {
|
||||||
*/
|
*/
|
||||||
public static function insert_post( $id, $data ) {
|
public static function insert_post( $id, $data ) {
|
||||||
if ( preg_match_all( '/' . ACTIVITYPUB_HASHTAGS_REGEXP . '/i', $data->post_content, $match ) ) {
|
if ( preg_match_all( '/' . ACTIVITYPUB_HASHTAGS_REGEXP . '/i', $data->post_content, $match ) ) {
|
||||||
$tags = implode( ', ', $match[2] );
|
$tags = implode( ', ', $match[1] );
|
||||||
|
|
||||||
wp_add_post_tags( $data->post_parent, $tags );
|
wp_add_post_tags( $data->post_parent, $tags );
|
||||||
}
|
}
|
||||||
|
@ -59,16 +59,15 @@ class Hashtag {
|
||||||
* @return string the final string
|
* @return string the final string
|
||||||
*/
|
*/
|
||||||
public static function replace_with_links( $result ) {
|
public static function replace_with_links( $result ) {
|
||||||
$tag = $result[2];
|
$tag = $result[1];
|
||||||
$space = $result[1];
|
$tag_object = get_term_by( 'name', $result[1], 'post_tag' );
|
||||||
$tag_object = get_term_by( 'name', $result[2], 'post_tag' );
|
|
||||||
|
|
||||||
if ( $tag_object ) {
|
if ( $tag_object ) {
|
||||||
$link = get_term_link( $tag_object, 'post_tag' );
|
$link = get_term_link( $tag_object, 'post_tag' );
|
||||||
return "$space<a href='$link' rel='tag'>#$tag</a>";
|
return sprintf( '<a rel="tag" class="u-tag u-category" href="%s">#%s</a>', $link, $tag );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $space . '#' . $tag;
|
return '#' . $tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,6 +13,7 @@ class Test_Activitypub_Hashtag extends WP_UnitTestCase {
|
||||||
return [
|
return [
|
||||||
[ 'test', 'test' ],
|
[ 'test', 'test' ],
|
||||||
[ '#test', '#test' ],
|
[ '#test', '#test' ],
|
||||||
|
[ 'hallo #test test', 'hallo #test test' ],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue