#24011 closed task (blessed) (invalid)
Consider hiding post title for "Status" and "Aside" formats and autogenerating
Reported by: | markjaquith | Owned by: | nacin |
---|---|---|---|
Milestone: | Priority: | high | |
Severity: | blocker | Version: | 3.6 |
Component: | Post Formats | Keywords: | needs-patch |
Focuses: | Cc: |
Description (last modified by )
The status and asides post formats shouldn't have a title. The only reason for having a title is to generate a slug. We should consider hiding the post title for these formats, and auto-generating a title based on the first X chars of the post, P2 style.
Attachments (18)
Change History (79)
#1
@
12 years ago
- Description modified (diff)
- Summary changed from Consider hiding post title for "Status" format and autogenerating to Consider hiding post title for "Status" and "Aside" formats and autogenerating
#3
follow-up:
↓ 4
@
12 years ago
- Keywords has-patch added
In 24011.diff:
- For empty titles in asides and status posts, generate a title from post content or format
- Return an empty string for
get_the_title
for statuses and asides on the front-end
Not sure how many existing themes show post titles for asides and statuses, but if they do, this approach might seem "broken." What if the post title is hidden only if it's auto-generated?
#4
in reply to:
↑ 3
@
12 years ago
Replying to kovshenin:
What if the post title is hidden only if it's auto-generated?
Does that actually happen/is that actually done?
I think I've noted this in at least one of my Make/Core posts, but I would really prefer that the title still be editable on the screen somehow, probably through a toggle or some such. I also wonder if we can do some smart auto-generating for some other formats if a user leaves the title blank, whether or not the title field is hidden for that format.
#5
@
12 years ago
Replying to helen:
Does that actually happen/is that actually done?
Nope. I meant to propose for the post title to be hidden only when auto-generated. Sorry if it sounded otherwise :)
In 24011.2.diff:
- Hook in earlier at
wp_insert_post_data
to avoid multiple queries - Re-generate the post title during an update if it was auto-generated
- Hide the post title in
get_the_title
only if it was auto-generated
#6
follow-up:
↓ 7
@
11 years ago
24011.2.diff looks ok when working with a single post, but on my 3.6 beta site I'm running into problems with batch editing posts:
Notice: Undefined index: post_format in /wp-includes/post-formats.php on line 843
Looks like $postarr doesn't have 'post_format' available for wp_insert_post_data
#10
in reply to:
↑ 7
@
11 years ago
#12
@
11 years ago
Refreshed in 24011.5.diff, additionally:
- Hides the title field on the edit screen for asides and status posts
- Does not hide auto-generated titles in RSS feeds
- Works when bulk editing
#14
follow-up:
↓ 15
@
11 years ago
I've only just spotted this, but WHY should status and aside posts not have a title? I, for example, quite like being able to show the title on the single post views. Is there going to be a way to disable this particular "addition" or not?
#15
in reply to:
↑ 14
;
follow-up:
↓ 16
@
11 years ago
Replying to markmcwilliams:
I've only just spotted this, but WHY should status and aside posts not have a title? I, for example, quite like being able to show the title on the single post views.
They do have a title. Hiding an edit field for something does not mean it's not there. Hiding and utogenerating means you don't have to write it.
Whether titles are used on single post views is theme dependent.
#16
in reply to:
↑ 15
;
follow-up:
↓ 17
@
11 years ago
Replying to knutsp:
Replying to markmcwilliams:
I've only just spotted this, but WHY should status and aside posts not have a title? I, for example, quite like being able to show the title on the single post views.
They do have a title. Hiding an edit field for something does not mean it's not there. Hiding and utogenerating means you don't have to write it.
Whether titles are used on single post views is theme dependent.
What I'm getting at is I don't wish for my titles to be auto-generated!
#17
in reply to:
↑ 16
;
follow-up:
↓ 19
@
11 years ago
Replying to markmcwilliams:
What I'm getting at is I don't wish for my titles to be auto-generated!
I think this handling of titles reflects the definition of what the formats aside and status is about. You don't write a title to a status post on services like Twitter and Facebook, for instance. If you want your own titles you select another post format, like standard.
#18
@
11 years ago
- Cc justin@… added
I thought we had already previously decided that we'd allow users to at least have access to editing the title for all post formats as Helen mentioned above. Whether this is done via a toggle, screen option, or whatever, it should be easy to do.
Many of us who've been using asides for years are accustomed to being able to write custom titles. Even Matt does this at http://ma.tt/type/aside (check single posts). I won't even get started on the SEO folks who'll want to have total control over this.
I actually like the idea of an auto-generated title (for all posts) if the title field is left empty.
#19
in reply to:
↑ 17
;
follow-up:
↓ 20
@
11 years ago
- Cc info@… added
Replying to knutsp:
I think this handling of titles reflects the definition of what the formats aside and status is about. You don't write a title to a status post on services like Twitter and Facebook, for instance. If you want your own titles you select another post format, like standard.
I find that compelling for statuses but not asides. People get these two stati confused all the times and leaving the title for asides might actually be a good way to help make that clarification.
Generally, being able to [easily] edit the title strikes me as a fairly reasonable request for those who want full editorial control, even if only displayed backend. And how is Quick Edit affected by this change? If it's not at all, that only makes hiding the title that much more confusing.
+1 @greenshady to auto-generated titles on anything without a title.
#20
in reply to:
↑ 19
@
11 years ago
Replying to mrwweb:
I find that compelling for statuses but not asides. People get these two stati confused all the times and leaving the title for asides might actually be a good way to help make that clarification.
Makes sense to me.
#21
@
11 years ago
I'm good with keeping restoring the title for aside, but keeping the autogen code for when it's blank, and the filters on the front end. Aside has a lot of history, and a lot of people might be used to custom titles.
Separately, we have another issue, in that the code that autofocuses the title should autofocus the content for post formats that hide the title.
#23
in reply to:
↑ 13
@
11 years ago
There's a regression introduced in 24043
In _post_formats_fix_empty_title():
$post_id = ( isset( $postarr['ID'] ) ) ? absint( $postarr['ID'] ) : 0; if ( $post_id ) $post_format = get_post_format( $post_id ); if ( isset( $postarr['post_format'] ) ) $post_format = ( in_array( $postarr['post_format'], get_post_format_slugs() ) ) ? $postarr['post_format'] : ''; if ( ! in_array( $post_format, array( 'aside', 'status' ) ) ) return $data;
When you wp_insert_post() without passing a post_format, neither $post_id nor $postarrpost_format? are set, so that $post_format in the last if throws a warning because it's undefined.
#25
@
11 years ago
24011.6.diff fixes the issue in comment:23
#26
@
11 years ago
24011.7.diff is a slightly different approach at the issue above.
#28
@
11 years ago
[24043] caused a significant increase in traffic to the posts cache on wordpress.com. Commenting out the add_action()s in default-filters.php brought the cache traffic back to normal.
#29
@
11 years ago
Restored the _post_formats_fix_empty_title action. Traffic remained normal. So, _post_formats_title appears to be the culprit.
#30
follow-up:
↓ 32
@
11 years ago
It looks like the function is too heavy and the_title
filter is called a bazillion times in a request. Seems like get_post()
and get_post_format()
are causing cache hits. 24011.8.diff implements a little internal cache with a static array. Here are some measurements I took:
Cache hits | Increase | |
No filter | 2174 | 0% |
r24043 | 2398 | 10.30% |
24011.8.diff | 2194 | 0.91% |
Feedback appreciated, and @ryan please let me know if this does the trick. Thanks!
#31
@
11 years ago
In general, I like to avoid adding caches other than those managed by WP_Object_Cache. I haven't investigated yet, but this feels like something that needs to be fixed lower down.
#32
in reply to:
↑ 30
@
11 years ago
I guess some kind of caching would make sense here, as we don't need to regenerate and verify the title each time the_title
filter runs for the same post.
#33
@
11 years ago
kovshenin, are you seeing local cache hits or remote? With both wordpress.com and trunk, I'm not seeing any extra remote cache hits with the action enabled. This is with several aside and status posts so _post_formats_generate_title() is being run. I see extra local cache hits with the filter enabled, but no extra remote cache hits. I'm not sure why we're seeing increased remote hits in aggregate on wordpress.com.
#34
@
11 years ago
Also worth noting that those kinds of static cache keys don't work right when the blog is switched. You could add the blog ID into the cache key, but at that point, it becomes obvious you should use the object cache.
#35
follow-up:
↓ 36
@
11 years ago
@nacin, you're right, didn't think of that :(
@ryan, local. I haven't tested it with external cache, but I can try if it helps. I'm no cache guru but I assumed every cache get was sent to external cache, and now I see there's a $force
argument there, at least in the memcached plugin on .org, not entirely sure how that's used in the wild.
#36
in reply to:
↑ 35
@
11 years ago
Replying to kovshenin:
@ryan, local. I haven't tested it with external cache, but I can try if it helps. I'm no cache guru but I assumed every cache get was sent to external cache, and now I see there's a
$force
argument there, at least in the memcached plugin on .org, not entirely sure how that's used in the wild.
External cache hits only occur once. Then it gets stored locally for future retrieval on that page. Local cache hits are just fine. $force relatively new and is only there for the rare instance when you need to hit external cache again (like when you are using an external object cache for locking a process — we use it for cron locking). Most object cache backends likely don't yet even support $force; they go straight to local no matter what.
Local cache hits are fine. It's no different than a local array, just with the overhead of an extra few function calls.
#37
@
11 years ago
Some plugins and themes (including P2) seem to use the_title
filter with apply_filters
without a post context. This can cause missing argument warnings in _post_formats_title
. 24011.9.diff addresses that.
#38
follow-up:
↓ 39
@
11 years ago
Me, from #24013:
I'd rather we not ever hide the Title field, and instead disable it and change the "Enter title here" text to say "Not used for this format" -- it will cut down on the jumpiness and unpredictability of hiding core fields that have been around for a decade, and isn't as jarring to existing users that need to learn the new UI.
#39
in reply to:
↑ 38
@
11 years ago
Replying to johnjamesjacoby:
Me, from #24013:
I'd rather we not ever hide the Title field, and instead disable it and change the "Enter title here" text to say "Not used for this format" -- it will cut down on the jumpiness and unpredictability of hiding core fields that have been around for a decade, and isn't as jarring to existing users that need to learn the new UI.
It would certainly cut down on the "Where did the title field go?" questions that are bound to come in?
I'd still rather have *some way* of editing it, for freaks such as myself! o_O
#41
follow-up:
↓ 43
@
11 years ago
I'm in the club of people who assigns titles to aside and status posts.
Instead of hiding it or saying "Not used for this format", how about "Enter title here (optional)" on those formats that would get an auto-generated title if left blank?
#43
in reply to:
↑ 41
@
11 years ago
Replying to mindctrl:
I'm in the club of people who assigns titles to aside and status posts.
Instead of hiding it or saying "Not used for this format", how about "Enter title here (optional)" on those formats that would get an auto-generated title if left blank?
1+
The title input is very helpful, Sometimes I need to create a unique post title ever for 'Status' format.. the post title not only shown in the front-end it's also helpful in the back-end and custom queries.
In also showing Asides and Status title in the front-end is depending on the theme, I can't say that if theme show the Status title is wrong...
My opinion is:
1- Show the post title input with a opacity and "Enter title here (optional)" place-holder.
2- When the user publish the Aside/Status post with an empty title, leave it blank even in the database ( The database should only contain the user input not something that auto-generated ).
3- Hook the get_the_title filter to show the fall-back title ( title based on the first X chars of the post content ) in the Admin & Feed and only if there is not a real post title.
I really don't like when WordPress make a strict rules about how I must design the theme or mange the website.. So keep it free as possible.
#45
@
11 years ago
24011.12.diff sets the opacity for the title element to 50% for status and aside, and sets it back to 100% when focused. It also auto-focuses on the content for those types instead of the title.
#46
@
11 years ago
24011.13.diff changes the title prompt text to indicate that it is optional for status/aside (well, MORE optional than usual). Changes some variable names.
#47
@
11 years ago
- Keywords commit added
I noticed one small issue with .13
. When I edited an existing status or aside post the title wasn't faded until after I focused in and back out, or after changing the post format and changing it back. 24011.14.diff fixes that.
As far as I can tell, everything looks good now.
#48
follow-up:
↓ 50
@
11 years ago
Having one filter for two different strings (Enter title here
/Enter title here (optional)
) seems weird. Perhaps a third boolean arg $optional.
#49
@
11 years ago
I am wondering if there is an easy way to know if the Aside/Status title is auto-generated or custom ?!
#50
in reply to:
↑ 48
@
11 years ago
Replying to ocean90:
Having one filter for two different strings (
Enter title here
/Enter title here (optional)
) seems weird. Perhaps a third boolean arg $optional.
A third arg sounds good.
#51
follow-up:
↓ 53
@
11 years ago
In 24011.16.diff I just added a true/false as the third arg with a note that says "Third argument passed to filter denotes optional title field"
Let me know if you have any preferences beyond that.
#52
@
11 years ago
People have been getting dark about boolean args - I personally have no problem with them, just beware
#53
in reply to:
↑ 51
;
follow-up:
↓ 54
@
11 years ago
Replying to aaroncampbell:
In 24011.16.diff I just added a true/false as the third arg with a note that says "Third argument passed to filter denotes optional title field"
Could we make that 'optional'/'required'
for clarity (per our coding standards)?
#54
in reply to:
↑ 53
@
11 years ago
Replying to SergeyBiryukov:
Could we make that
'optional'/'required'
for clarity (per our coding standards)?
Should have done that to begin with. Changed in 24011.17.diff
#55
@
11 years ago
- Milestone 3.6 deleted
- Resolution set to invalid
- Status changed from new to closed
#56
@
11 years ago
- Milestone set to 3.6
- Resolution invalid deleted
- Status changed from closed to reopened
This ticket falls under "Post Format Things to Keep in Core", per the post on make/core.
#24452 didn't touch [24043]. Looks like we still have a performance issue to deal with: comment:28.
#58
@
11 years ago
- Keywords needs-patch added; has-patch commit removed
- Severity changed from normal to blocker
Bumping up the severity. Needs a patch for the above.
#59
@
11 years ago
I spent a fair amount of time with this today and could not really find where it all goes wrong, at least in core. I added the following piece of code to the filter callback.
$group = 'posts'; $key = $wp_object_cache->key( $post_id, $group ); if ( ! isset( $wp_object_cache->cache[ $key ] ) ) { error_log( sprintf( 'key not set: %s on %s', $key, $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) ); }
This checks whether the passed in post id is already in the local cache, and if it's not, it means that the following calls to get_post_format
and get_post
will fetch the remote cache. I haven't got a single entry while browsing trunk with a few plugins. Not a single entry.
I tried the same experiment on WordPress.com and I did get a few entries. I'm looking further into it now, but it seems like get_the_title
in conjunction with get_post
is slightly misbehaving.
Are saying that the title field should not be available when creating a new post?
Because as of now, both Twenty Thirteen and Sempress, do not show the title of a Status or a Aside post format.