Make WordPress Core

Opened 13 years ago

Closed 7 years ago

#18692 closed enhancement (maybelater)

wp_insert_post() enhancements

Reported by: sirzooro's profile sirzooro Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.2.1
Component: Posts, Post Types Keywords: needs-patch
Focuses: Cc:


I have created enhancement for wp_insert_post() function. There re two changes:

  • allows to return WP_Error from wp_insert_post_data - in this case function returns that value (or 0 if param $wp_error == false) and do not continue;
  • filter categories, tags and other taxonomies through new filters: wp_insert_post_category, wp_insert_post_tags and wp_insert_post_tax. New code also checks if these filters returned WP_Error;

These changes will allow me to implement following features in my WyPiekacz plugin:

  • do not create new post when it does not satisfy appropriate rules. Although WP code will not display that error by itself (#10480, #18266), I will be able to display appropriate error from plugin code (at least when normal editor was used). This will also help me to stop flood of automated post spam;
  • allow to review tags attached to post submitted for review - this way tags will be actually created when post will be published; before this they will be stored as post metadata. In order to do this I need to modify tags - unfortunately wp_insert_post_data filter does not allow to modify them (it allows read-only access to them only).

Attachments (1)

post.php.diff (1.9 KB) - added by sirzooro 13 years ago.

Download all attachments as: .zip

Change History (9)

13 years ago

#1 @mikeschinkel
13 years ago

  • Cc mikeschinkel@… added
  • Keywords dev-feedback added

+1 for the control (I'll defer comments on coding style to core committers.)

Related #18713

Last edited 13 years ago by mikeschinkel (previous) (diff)

#2 @sirzooro
12 years ago

It will be good to provide integration with XML-RPC too - recently it was enabled globally, so I expect more automated publishing tools will start using it in near future.

#4 @wonderboymusic
10 years ago

  • Keywords needs-refresh added; dev-feedback removed

#5 @DrewAPicture
10 years ago

  • Component changed from General to Posts, Post Types
  • Keywords close reporter-feedback added

Any continued interest in pursing this?

#6 @sirzooro
10 years ago

  • Keywords close reporter-feedback removed

Yes, I am still interested in fixing this. Now the only way to add functionality mentioned at the beginning is to directly modify POST data before WP puts his hands on it, and messing up executed SQL query. Both solutions are hacks, and 2nd one is especially ugly.

#7 @chriscct7
9 years ago

  • Keywords needs-patch added; has-patch needs-refresh removed

#8 @swissspidy
7 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from new to closed

Closing this as 'maybelater' as there's been no traction in over 2 years. The suggested changes sound interesting, but this ticket would need an owner. Feel free to reopen when a patch emerges.

Note: See TracTickets for help on using tickets.