diff --git a/likecoin/admin/matters.php b/likecoin/admin/matters.php index 20b19f7f..6c6557c6 100644 --- a/likecoin/admin/matters.php +++ b/likecoin/admin/matters.php @@ -452,7 +452,7 @@ function likecoin_save_to_matters( $post_id, $post, $update = true ) { } $matters_draft_id = isset( $matters_info['draft_id'] ) ? $matters_info['draft_id'] : null; $title = apply_filters( 'the_title_rss', $post->post_title ); - $tags = likecoin_get_post_tags( $post ); + $tags = likecoin_get_post_tags( $post, 5 ); $api = LikeCoin_Matters_API::get_instance(); if ( $update && $matters_draft_id ) { @@ -507,7 +507,7 @@ function likecoin_publish_to_matters( $post_id, $post ) { } $matters_draft_id = isset( $matters_info['draft_id'] ) ? $matters_info['draft_id'] : null; $title = apply_filters( 'the_title_rss', $post->post_title ); - $tags = likecoin_get_post_tags( $post ); + $tags = likecoin_get_post_tags( $post, 5 ); $api = LikeCoin_Matters_API::get_instance(); if ( ! $matters_draft_id ) { $content = likecoin_filter_matters_post_content( $post ); diff --git a/likecoin/admin/post.php b/likecoin/admin/post.php index fa49d18a..0bbc4084 100644 --- a/likecoin/admin/post.php +++ b/likecoin/admin/post.php @@ -167,8 +167,9 @@ function likecoin_get_default_post_style() { * Get all tags names in a post * * @param WP_Post| $post Post object. + * @param integer| $limit Number of tags. */ -function likecoin_get_post_tags( $post ) { +function likecoin_get_post_tags( $post, $limit = 0 ) { $post_id = $post->ID; $func = function( $terms ) { return htmlspecialchars_decode( $terms->name ); @@ -178,7 +179,11 @@ function likecoin_get_post_tags( $post ) { if ( ! $post_tags ) { $post_tags = array(); } - return array_map( $func, $post_tags ); + $result = array_map( $func, $post_tags ); + if ( $limit ) { + $result = array_slice( $result, 0, $limit ); + } + return $result; } /**