Opened 4 years ago

Closed 21 months ago

#9657 closed enhancement (invalid)

Allow custom screen_meta dropdown panels

Reported by: hakre Owned by: ptahdunbar
Priority: normal Milestone:
Component: Administration Version: 3.0
Severity: normal Keywords: has-patch dev-feedback westi-likes
Cc: WordPress@…, rspindel, mikeschinkel@…, trac@…, steph@…, bill.erickson@…

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)

9657-demo-template-for-plugin-v0.1.patch (2.5 KB) - added by hakre 4 years ago.
First patch for template.php
9657-demo-template-for-plugin-v0.1.2.patch (2.5 KB) - added by hakre 4 years ago.
first demo plugin
9657-extra-metas-v0.1.php (4.9 KB) - added by hakre 4 years ago.
Demo Plugin v0.1
9657-extra-metas-v0.2.php (1.8 KB) - added by hakre 4 years ago.
Test Plugin v0.2 for the next Patchset
9657.patch (13.7 KB) - added by hakre 4 years ago.
Fully Patched.
9657.2.patch (13.5 KB) - added by hakre 4 years ago.
missing . (dot) and a wrong brace-location corrected
9657.3.patch (13.7 KB) - added by hakre 4 years ago.
deb0rked
9657-plugin.php (1.8 KB) - added by hakre 4 years ago.
Minor Testplugin update (Naming)
breadcrumb-navxt-3.2-00-better-ui-overview.png (20.0 KB) - added by hakre 4 years ago.
Example Implementation Screenshot (Closed)
breadcrumb-navxt-3.2-01-xml-import-export-tool.png (22.4 KB) - added by hakre 4 years ago.
Example Implementation Screenshot (Opened)
9605.diff (700 bytes) - added by Denis-de-Bernardy 4 years ago.
patch is by arena
screen-meta-sample-code.txt (2.8 KB) - added by alexkingorg 4 years ago.
Sample code for fully abstracting/filtering screen meta tabs and generic CSS and JS
ticket.9657.diff (15.1 KB) - added by ptahdunbar 2 years ago.
first pass for proper screen meta API
ticket.9657.2.diff (16.2 KB) - added by ptahdunbar 2 years ago.
second pass for screen meta api. bug fixes and improvements

Download all attachments as: .zip

Change History (61)

comment:1 follow-up: ↓ 2   mtekk4 years ago

  • Milestone changed from 2.8 to 2.9

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.

hakre4 years ago

First patch for template.php

hakre4 years ago

first demo plugin

hakre4 years ago

Demo Plugin v0.1

comment:2 in reply to: ↑ 1   hakre4 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.

hakre4 years ago

Test Plugin v0.2 for the next Patchset

hakre4 years ago

Fully Patched.

  • 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.

ie7 test passed.

see also (dup): #9605

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.

  • Keywords second-opinion added
  • Keywords developer-feedback added
  • Keywords 2nd-opinion added; second-opinion removed

In the latest patch, shouldn't:

screen-metas-link-wrap {

be a class or an ID instead?

  • Keywords dev-feedback added; developer-feedback removed
  • Keywords 2nd-opinion removed

should apparently be a dot. the idea is good imo.

you are right my fault, I'll update the patch

hakre4 years ago

missing . (dot) and a wrong brace-location corrected

  • Keywords 2nd-opinion added
  • Keywords tested added; dev-feedback removed

patch doesn't break anything

  • Milestone changed from 2.8 to Future Release

patch is b0rke

hakre4 years ago

deb0rked

hakre4 years ago

Minor Testplugin update (Naming)

  • Milestone changed from Future Release to 2.8

Patch updated to latest revision.

any interest, or shall we punt?

  • Keywords dev-feedback added

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.

hakre4 years ago

Example Implementation Screenshot (Closed)

hakre4 years ago

Example Implementation Screenshot (Opened)

  • Keywords early added
  • Milestone changed from 2.8 to 2.9

no apparent interest...

That's a pitty.

patch is by arena

added another potential patch by arena

comment:24 in reply to: ↑ 23   arena4 years ago

Replying to Denis-de-Bernardy:

added another potential patch by arena

Merci !

  • Keywords needs-review added; 2nd-opinion dev-feedback removed

Sample code for fully abstracting/filtering screen meta tabs and generic CSS and JS

@alexkingorg: please see file 9657.patch

  • Summary changed from meta links filters to Allow custom screen_meta dropdown panels

+1

  • Milestone changed from 2.9 to Future Release
  • Version changed from 2.8 to 3.0

Related: #1151

Related: #11517

Related: [12553] - this move of files should be reflected in my patches

what's the status on the patch?

  • Cc WordPress@… added

Plugin authors should be able to add tabs.

  • Cc rspindel added
  • Cc mikeschinkel@… added
  • Cc trac@… added
  • Keywords 3.2-early added
  • Owner changed from anonymous to ptahdunbar
  • Status changed from new to accepted
  • 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.

  • 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

first pass for proper screen meta API

  • 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.

Last edited 2 years ago by ptahdunbar (previous) (diff)
  • 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.

Could you also upload an mu-plugins drop-in with example usage?

second pass for screen meta api. bug fixes and improvements

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
}
  • Keywords has-patch westi-likes added

I like the way this is going in creating a clear api for this - not 3.2 material though

  • Cc steph@… added
  • Cc bill.erickson@… added
  • Milestone Future Release deleted
  • Resolution set to invalid
  • Status changed from accepted to closed

Since the admin header was blended into the admin bar (#18197), there are no more meta panels.

You can just add stuff to the admin bar, which already has an API.

Note: See TracTickets for help on using tickets.