WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#13386 closed enhancement (fixed)

Add ability to filter the text "Enter title here" which appears within the title's input box

Reported by: goto10 Owned by: nacin
Milestone: 3.1 Priority: normal
Severity: normal Version: 3.0
Component: Administration Keywords: needs-patch
Focuses: Cc:

Description

I'm adding a custom post type where a title is not exactly appropriate. Instead, I'd like to use a person's name, and I would like to update the grey text to reflect that.

Removing 'title' from 'supports' in register_post_type() seems like a bad idea. I was able to do this in 3.0 beta1, but doing so caused various issues. It removed the ability to edit the permalink, removed the convenient link to the post on the edit post listing page, and probably other things. In 3.0 beta2, removing "title" from the "supports" options on a custom post type no longer functions at all.

For now, I'll do it with javascript, but a cleaner solution would be ideal.

The relevant code/text is here:
Line 196 in wp-admin/edit-form-advanced.php using 3.0 beta2

Change History (10)

#1 @nacin
7 years ago

Two issues here:

  1. I have no problem offering a filter for 'Enter title here', which I added for UX reasons. That said, you can already filter it through A) the gettext filter, or B) JS, or C) hide it all together with CSS (#title-prompt-text).
  1. I'm more concerned with the functionality of removing 'title' from the 'supports' options. How does it no longer work?

#2 @goto10
7 years ago

Hi nacin,

Thanks for the follow-up.

For 1.) I think the "Enter title here" text works well for the UX. Since the title is special, in that it is tied to the permalink functionality and is arguably needed for the post listing page, it seems that it is important to keep it around. That is, unless new functionality is created for handling the changing of permalinks, etc.

So, with things as they are, I do think there should be a system in place for re-purposing the title field, when it is necessary. The methods you listed for changing the text are well and good, but extra considerations need to be made to ensure that these changes are only occurring on certain pages. For instance, in my case, I've added a 'testimonials' post type. I want to change the title-prompt-text to "Enter name here" on my testimonials post type, but leave the default text on posts and pages. This is doable, but seems like a little more work than it should be. For example, an extra option in register_post_type() for #title-prompt-text would be nice.

...And 2.) Well, I've done some further testing, and I am able to remove the title input box in beta 2 after all. In previous tests, I had commented out all of the features from supports one by one, eventually ending up with an empty array of options. Using 'supports' => array() will cause the title to show up, but 'supports' => array('editor') will hide the title in beta2. This is probably another issue entirely, but it does seem to me that only options explicitly added to supports should show up.

#3 @anointed
7 years ago

  • Cc anointed added

#4 @t31os_
7 years ago

@goto10 - I believe the arguments for supports, like many other WordPress functions has a set of defaults, if you don't declare a setting, true / false, or a particular value it is given an assumed default value.

#5 @goto10
7 years ago

@t31os_ - I gotcha. Fair enough on that. I think I was "off" on point 2 from nacin's post. It's really a different matter than the title prompt text anyway.

After pondering this a bit more, and learning of the new "labels" argument for register_post_type, I'm thinking that a new label parameter would be suitable for the title prompt text (vs a filter, as I had originally proposed).

Also, having a new label argument for the title's column header text on the manage edit posts screen would be cool. Since the title's column header text is already filterable, I think that this would be feasible.

One could make the point that you can just add the filter for the title's column header already without the need for a core enhancement, just as nacin pointed out work-arounds for the title prompt text. But, I'm looking to do as much as possible all at once with just a single call to register_post_type(). I feel like these proposals are pretty well in-line with what the labels parameter is doing.

#6 @Ornani
7 years ago

I think adding this as a new label is the perfect solution for this issue.

#7 @johnkolbert
7 years ago

  • Cc johnkolbert added

#8 @nacin
7 years ago

  • Milestone set to 3.1
  • Owner set to nacin
  • Status changed from new to reviewing

#9 @jane
7 years ago

  • Keywords needs-patch added

If anyone wants to get this in for 3.1, a patch needs to be posted now, as freeze is coming up very soon.

#10 @nacin
7 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

(In [16247]) enter_title_here filter. fixes #13386.

Note: See TracTickets for help on using tickets.