Opened 16 years ago
Closed 13 years ago
#9657 closed enhancement (invalid)
Allow custom screen_meta dropdown panels
Reported by: | hakre | Owned by: | ptahdunbar |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.0 |
Component: | Administration | Keywords: | has-patch dev-feedback westi-likes |
Focuses: | Cc: |
Description
It would be nice for plugins to have their own meta links (next to help) on their admin page(s).
For example, for a plugin, I was able to hack some stuff with javascript and reuse the (unused) second tab (known as 'display options') to inject own stuff (see attached pictures, compare to current breadcrumb navxt svn code). but that is a somehow stinky hack that I as plugin developer need to take care of for each WP release. It would be nice to have an api for that adding 0-n of such tabs by a hook returning a title and content.
therefore the javascript needs a little tweak to handle additional tabs, the stylesheet should be adopted sothat it is more lightweight and can handle all tabs at once (currently using ids). a test-plugin can be provided to show the functionality.
then template.php needs to have the one or other addition in php code to create the hooks.
Attachments (14)
Change History (61)
#2
in reply to:
↑ 1
@
16 years ago
9657-demo-template-for-plugin-v0.1.2.patch is unneeded file (duplicate), it was uploaded by accident, please ignore / delete.
Replying to mtekk:
I don't think this will make 2.8 unless there is a patch available for it right now (2.8 is supposedly in a feature freeze). I'm going to move it to 2.9 for now.
first patchset is up. I will enhance it now for being a complete useable patch. then I will set it to has-patch.
#3
@
16 years ago
- Keywords has-patch added; needs-patch removed
- Milestone changed from 2.9 to 2.8
This is a full Patchset containing all PHP, CSS and JS Code. The Plugin has been reduced to demonstrate the usage of one of the hooks only.
screen_metas() in template.php has been rewritten to better reflect having 0-n screen_meta tabs.
new hook screen_meta_basic_metas can filter the basic screen_metas (that is contextual help and screen options)
hook screen_meta_extra_metas can be used to add own screen_metas (as the test plugin does).
some ie6 css code has been improved by the way.
tested against firfox 3, ie 6, opera 9 and chrome 1. ie 7 test pending.
this thingy is ready and really nice to have.
#6
@
16 years ago
should be more easy to adopt for the 2.8 changes (planned) as in http://wordpress.org/development/guidelines-for-2-8-navigation-design/
all "tabs" (screen metas I call them now) consists of a two part array: index 0: Name (the link/button you press) and the content (that is what will be displayed on press).
so this patch provides a kind of model (very lo-fi as usual with WP) for that area of the admin.
#10
@
16 years ago
In the latest patch, shouldn't:
screen-metas-link-wrap {
be a class or an ID instead?
#20
@
15 years ago
please put that in. for 2.7 this can only be faked and I would love to have the possibility in. It's a nice UI Feature that should be usable for plugin authors as well. As an exmaple I add a picture where you see an implementation for 2.7 looks like.
#27
@
15 years ago
- Summary changed from meta links filters to Allow custom screen_meta dropdown panels
+1
#38
@
14 years ago
- Cc trac@… added
- Keywords 3.2-early added
- Owner changed from anonymous to ptahdunbar
- Status changed from new to accepted
#39
@
14 years ago
- Keywords has-patch tested early needs-review removed
removed has-patch tested and needs-review as the patches are stale. I've got a hot one coming in.
#40
@
14 years ago
- Keywords changed from 3.2-early to 3.2-early 3.2-early
Replying to ptahdunbar:
removed has-patch tested and needs-review as the patches are stale. I've got a hot one coming in.
Cool! Duplicate: #9657
#41
@
14 years ago
- Keywords dev-feedback added
Alright, so here's my first pass at a proper screen meta api:
New functions:
- add_screen_meta_tab( $id, $label, $capability, $screen, $priority );
- add_screen_meta_section( $id, $callback, $tab, $priority, $callback_args );
- do_screen_meta();
The process is fairly simple. Hook into screen_meta; register a new "tab", then add "sections" to registered tabs. do_screen_meta() handles the rest.
I've converted the existing screen_meta mess into the api so you can see how it looks. It's a first pass so it doesn't have any remove_* functions or proper hooks/filters. Check it out and let me know if this is the direction you guys want to go.
You'll notice the tabs and sections use capabilities for some nice access control. They also use priorities so you can order the tabs and sections regardless of which was called first.
That's all for now. get this in quick while it's hot, or shoot me some feedback/suggestions.
#42
@
14 years ago
- Keywords 3.2-early 3.2-early removed
I think this should go into WP 3.2 only if we also make the tabs more proeminent.
A lot of users don't even know they can hide metaboxes, for example.
#44
@
14 years ago
Updated the patch with some bug fixes and improvements.
Here's an example usage. It adds two blank tabs to the dashboard as well as a global tab with some content.
add_action( 'screen_meta', 'how_to_screen_meta_api_example' ); function how_to_screen_meta_api_example() { add_screen_meta_tab( 'foobar', __( 'Foobar' ), 'dashboard' ); add_screen_meta_tab( 'barfoo', __( 'Barfoo' ), 'dashboard', 'read', 8 ); add_screen_meta_tab( 'new-tab', __( 'This is a new tab' ), 'global' ); add_screen_meta_section( 'example-1', 'how_to_example_1', 'new-tab' ); add_screen_meta_section( 'example-2', 'how_to_example_2', 'new-tab', 9 ); } function how_to_example_1() { ?> <h5>Example 1</h5> <p>This is an example of how to add a custom screen meta section. w00t!</p> <?php } function how_to_example_2() { ?> <h5>Example 2</h5> <p>Anything can go inside here. Maybe a form? Totally. Although, you'll still have to do all the heavy lifting etc.</p> <p>How about some lorem ipsum? Sure, why not.</p> <p>Nullam auctor suscipit orci sit amet accumsan. Suspendisse sit amet lectus nibh, et scelerisque diam. Nullam tincidunt, lectus id vestibulum venenatis, libero enim porta magna, sed scelerisque erat massa et arcu. Nulla quis vehicula turpis. Vestibulum pulvinar nunc eget lorem interdum nec placerat justo commodo. Proin auctor lacus sed mauris posuere vehicula. Quisque sed urna vel magna rutrum euismod. Mauris dictum lectus vel tellus posuere varius ut et dolor. Ut tortor libero, pulvinar at vehicula a, hendrerit nec orci. Ut dictum, mauris a vehicula commodo, nisi ligula porttitor magna, id vehicula odio lectus in sapien.</p> <?php }
I don't think this will make 2.8 unless there is a patch available for it right now (2.8 is supposedly in a feature freeze). I'm going to move it to 2.9 for now.