Open toolstack opened 8 months ago
Thank you! I'd be cautious about looping over the categories and terms (what if there are many).
As this is only done when submitting a post, the overhead hit seems like a reasonable compromise (see below for why). Even if there are a few hundred or thousand terms, that's not a lot of overhead.
What about using regex to extract the tags and then searching for them using the
name
parameter ofget_terms()
which is used in the background forget_categories()
andget_tags()
.
Could, but a regex is more challenging as WP allows for terms that have spaces in them, so searching for terms as defined by WP is probably more desirable. Looping through the terms makes catching the tags with spaces easy as we know what we're looking for.
Could, but a regex is more challenging as WP allows for terms that have spaces in them, so searching for terms as defined by WP is probably more desirable. Looping through the terms makes catching the tags with spaces easy as we know what we're looking for.
Interesting, so in your opinion there should be support for specifying a category or tag like this #category with space in it
vs. the slug notation like #category-with-space-in-it
?
Yes
Interesting, so in your opinion there should be support for specifying a category or tag like this
#category with space in it
vs. the slug notation like#category-with-space-in-it
?
Yes, most users don't know what a slug is, so letting them simply type in "#category name I always see" makes more sense here I think.
Yes, most users don't know what a slug is, so letting them simply type in "#category name I always see" makes more sense here I think.
In fact I think there might be an argument to check for three different kinds of tagging; "#this is a tag", "#this-is-a-tag", and "#thisisatag".
Aka, replacing spaces with dashes and removing spaces completely and searching for all three in the content.
I also think it might make sense to check the last line of the content and see if after tags, there's nothing left and if so, remove it.
Both are for future thought though 😁
During a post submission, scan the body for anything that matches a category or tag name (case insensitively) that starts with a hashtag and add that to the new post_data array.