Opened 11 years ago
Closed 9 years ago
#27056 closed enhancement (fixed)
Add hook for custom post.php actions
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.6 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Posts, Post Types | Keywords: | good-first-bug has-patch |
Focuses: | Cc: |
Description
I find myself in a situation where I'd like to use the post.php page to handle some custom actions. It seems pretty trivial and harmless to add an action hook to the default case of the switch statement.
Attachments (7)
Change History (25)
#2
@
11 years ago
- Keywords close added
Rather than use post.php, try using admin-post.php. Should do exactly what you're trying to do.
#3
@
11 years ago
Using admin-post.php is not an option because you cannot modify where edit-form-advanced.php posts to.
#4
@
9 years ago
- Keywords good-first-bug needs-docs needs-patch added; close removed
- Milestone changed from Awaiting Review to Future Release
perhaps a different name for the filter + docs
#5
@
9 years ago
The current patch by @Mte90 uses the name post_action_undefined
. I think instead we can create the action name dynamically like post_action_{$action}
.
@wonderboymusic Would you prefer that or do you have a different name in mind?
#6
@
9 years ago
- Keywords has-patch added; needs-patch removed
This is how I tested the patch I submitted:
Used a clean copy of WP (code, database) & tested the patch + the below action hook to successfully trigger the new action using
the site url + /wp-admin/post.php?post=1&action=asdflkjadsflkjasdf
(on clean installs this is the edit screen for the "Hello World" post)
The result was a page with just the words "Theme test", as expected.
<?php function second_theme_test(){ echo "Theme test"; die(); } add_action( 'post_action_asdflkjadsflkjasdf' , "second_theme_test" );
#8
@
9 years ago
- Milestone changed from Future Release to 4.5
- Owner set to brianvan
- Status changed from new to assigned
Assigning to mark the good-first-bug ticket "claimed".
This ticket was mentioned in Slack in #core by chriscct7. View the logs.
9 years ago
#10
@
9 years ago
I have added a period to the @param in phpdoc to @brianvan's patch so that it follows the WordPress Documentation standards.
This ticket was mentioned in Slack in #core by mte90. View the logs.
9 years ago
This ticket was mentioned in Slack in #core by jorbin. View the logs.
9 years ago
#13
follow-up:
↓ 14
@
9 years ago
- Keywords early added
- Milestone changed from 4.5 to Future Release
Sadly this has missed the 4.5 beta deadline for enhancements, let's take a look at it early in 4.6.
#14
in reply to:
↑ 13
@
9 years ago
Replying to jorbin:
Just a heads up that we should take a look at this before it slips again past 4.6. (Sorry if this is bad Trac etiquette; I don't otherwise know how I'd call this to the team's attention.)
This is low priority but also a really basic code addition.
#15
@
9 years ago
- Milestone changed from Future Release to 4.6
In 27056.4.patch I've adjusted the hook doc summary a bit and added a description for the dynamic portion of the hook name.
Moving to 4.6 for consideration.
Previously: #11068