Ticket #4991 (closed defect (bug): fixed)

Opened 5 years ago

Last modified 4 years ago

Edit post post_type should actually be the post_type

Reported by: filosofo Owned by: anonymous
Priority: normal Milestone: 2.5
Component: General Version: 2.3
Severity: normal Keywords: post_type edit has-patch
Cc: filosofo

Description

Lately for a couple of plugins I've created a custom post_type.

However, when editing a post, the post_type input field has hard-coded "post" as its value, meaning post_type is always overwritten as "post."

My patch sets the post_type field with whatever the post type actually is.

Attachments

edit_form_adv_post_type.diff Download (851 bytes) - added by filosofo 5 years ago.
sanitize_post_type.diff Download (411 bytes) - added by filosofo 5 years ago.
post_type.diff Download (1.3 KB) - added by ryan 5 years ago.
5740.diff Download (2.1 KB) - added by DD32 4 years ago.
patch from #5740

Change History

comment:1   ryan5 years ago

Some sanitization is probably in order if we allow arbitrary types. Perhaps add sanitize_title to the pre_post_type filter?

I added a patch to sanitize post_type. Please also see also #4844

ryan5 years ago

comment:3   ryan5 years ago

Since we've already fetched the post, we can use what's already there. See post_type.diff.

comment:4 follow-up: ↓ 6   lloydbudd4 years ago

Duplicated in #5740.

comment:5   ryan4 years ago

For the post_type sanitizer, we should use a less expensive function than sanitize_title() which does UTF-8 octet encoding and accent removal. Something more like sanitize_user() strict.

comment:6 in reply to: ↑ 4   DD324 years ago

Replying to lloydbudd:

Duplicated in #5740.

Whoops :)

I'll put my patch up here from that ticket anyway.

DD324 years ago

patch from #5740

comment:7   ryan4 years ago

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

(In [6712]) Don't hard code post type in edit forms. Props filosofo and DD32. fixes #4991

comment:8   ryan4 years ago

Changed it up a little to user get_default_post_to_edit() and get_default_page_to_edit() to set the default post_type and post_status.

Note: See TracTickets for help on using tickets.