#14083 closed defect (bug) (fixed)
Back compat for pages and categories for the load-$pagenow hook
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 3.0.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Administration | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
In WordPress 3.0 the URLs to create a post and edit a post are now all post-new.php and post.php, with the post type being passed in a GET parameter like so: post-new.php?post_type=page…meaning load-page-new.php and load-page.php action hooks have both vanished!
The attached patch:
- Adds in some backwards compatibility for the old load-page-new.php, load-page.php, and load-edit-categories.php hooks.
- Adds some new and useful dynamically constructed hooks based on the $typenow and $taxnow variables.
Attachments (3)
Change History (15)
#4
in reply to:
↑ 3
@
13 years ago
Replying to scribu:
It should either go in 3.0.1 or not at all.
Agreed... for the backwards compatibility hooks, but the new hooks proposal is valid on an ongoing basis.
#5
@
13 years ago
By the way, you should change the relative path in the patch (it's "Users/simon/Projects/HOI-WP/site/wp-admin/admin.php" currently).
#6
in reply to:
↑ description
;
follow-up:
↓ 7
@
13 years ago
- Component changed from General to Administration
Replying to simonwheatley:
- Adds some new and useful dynamically constructed hooks based on the $typenow and $taxnow variables.
"load-edit-tags.php-type-post-tax-category" is a bit of an unweildy hook name in my opinion. I don't think the hook name is the best place to pass so much context.
Would we not be better off sticking with "load-$pagenow" and passing the context (post type and taxonomy) as a parameter?
#7
in reply to:
↑ 6
@
13 years ago
Replying to johnbillion:
Replying to simonwheatley:
- Adds some new and useful dynamically constructed hooks based on the $typenow and $taxnow variables.
"load-edit-tags.php-type-post-tax-category" is a bit of an unweildy hook name in my opinion. I don't think the hook name is the best place to pass so much context.
Would we not be better off sticking with "load-$pagenow" and passing the context (post type and taxonomy) as a parameter?
You end up with more conditionals in the hooked function in the plugin if you pass more context, and as there's potentially a lot of different context this might feel a little messy. I like the idea of keeping the hooks precisely targetted, personally, but I guess it's a matter of taste... I do agree that the hooks end up pretty long.
Attaching a diff as per your suggestion so others can comment.
S
@
13 years ago
An alternative, as per JohnBillion's sugestions, which passes the type & taxonomy context as params rather than in the hook names
#9
@
13 years ago
- Keywords dev-feedback needs-testing removed
- Summary changed from Specific action hooks for different content types on load of the edit screen to Back compat for pages and categories for the load-$pagenow hook
- Type changed from enhancement to defect (bug)
It is much better to rely on the $current_screen object. And since these are globals, it is not like these are inaccessible. I suggest we add the back compat hooks, but drop the arguments.
Changing the title and making this a bug. Additional hooks or contexts can be discussed in a new ticket > 3.0.x.
@
13 years ago
Patch which only covers the backwards compatability (no alteration of existing hooks, no new hooks) against the current trunk, now with added speling, corrected code comment and elseif for (very) slight performance increase
It should either go in 3.0.1 or not at all.