WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 3 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)

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

Download all attachments as: .zip

Change History (61)

comment:1 follow-up: mtekk5 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.

hakre5 years ago

First patch for template.php

hakre5 years ago

first demo plugin

hakre5 years ago

Demo Plugin v0.1

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

hakre5 years ago

Test Plugin v0.2 for the next Patchset

hakre5 years ago

Fully Patched.

comment:3 hakre5 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.

comment:4 hakre5 years ago

ie7 test passed.

comment:5 hakre5 years ago

see also (dup): #9605

comment:6 hakre5 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.

comment:7 hakre5 years ago

  • Keywords second-opinion added

comment:8 hakre5 years ago

  • Keywords developer-feedback added

comment:9 hakre5 years ago

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

comment:10 Denis-de-Bernardy5 years ago

In the latest patch, shouldn't:

screen-metas-link-wrap {

be a class or an ID instead?

comment:11 Denis-de-Bernardy5 years ago

  • Keywords dev-feedback added; developer-feedback removed

comment:12 Denis-de-Bernardy5 years ago

  • Keywords 2nd-opinion removed

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

comment:13 hakre5 years ago

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

hakre5 years ago

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

comment:14 hakre5 years ago

  • Keywords 2nd-opinion added

comment:15 Denis-de-Bernardy5 years ago

  • Keywords tested added; dev-feedback removed

patch doesn't break anything

comment:16 Denis-de-Bernardy5 years ago

  • Milestone changed from 2.8 to Future Release

patch is b0rke

hakre5 years ago

deb0rked

hakre5 years ago

Minor Testplugin update (Naming)

comment:17 hakre5 years ago

  • Milestone changed from Future Release to 2.8

Patch updated to latest revision.

comment:18 Denis-de-Bernardy5 years ago

any interest, or shall we punt?

comment:19 Denis-de-Bernardy5 years ago

  • Keywords dev-feedback added

comment:20 hakre5 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.

hakre5 years ago

Example Implementation Screenshot (Closed)

hakre5 years ago

Example Implementation Screenshot (Opened)

comment:21 Denis-de-Bernardy5 years ago

  • Keywords early added
  • Milestone changed from 2.8 to 2.9

no apparent interest...

comment:22 hakre5 years ago

That's a pitty.

Denis-de-Bernardy5 years ago

patch is by arena

comment:23 follow-up: Denis-de-Bernardy5 years ago

added another potential patch by arena

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

Replying to Denis-de-Bernardy:

added another potential patch by arena

Merci !

comment:25 Denis-de-Bernardy5 years ago

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

alexkingorg5 years ago

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

comment:26 hakre5 years ago

@alexkingorg: please see file 9657.patch

comment:27 JohnLamansky5 years ago

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

+1

comment:28 ryan4 years ago

  • Milestone changed from 2.9 to Future Release

comment:29 hakre4 years ago

  • Version changed from 2.8 to 3.0

Related: #1151

comment:30 hakre4 years ago

Related: #11517

comment:31 hakre4 years ago

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

comment:32 ptahdunbar4 years ago

what's the status on the patch?

comment:33 voyagerfan57614 years ago

  • Cc WordPress@… added

comment:34 jane4 years ago

Plugin authors should be able to add tabs.

comment:35 rspindel4 years ago

  • Cc rspindel added

comment:37 mikeschinkel4 years ago

  • Cc mikeschinkel@… added

comment:38 ptahdunbar3 years ago

  • Cc trac@… added
  • Keywords 3.2-early added
  • Owner changed from anonymous to ptahdunbar
  • Status changed from new to accepted

comment:39 ptahdunbar3 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.

comment:40 hakre3 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

ptahdunbar3 years ago

first pass for proper screen meta API

comment:41 ptahdunbar3 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.

Last edited 3 years ago by ptahdunbar (previous) (diff)

comment:42 scribu3 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.

comment:43 scribu3 years ago

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

ptahdunbar3 years ago

second pass for screen meta api. bug fixes and improvements

comment:44 ptahdunbar3 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
}

comment:45 westi3 years ago

  • 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

comment:46 sillybean3 years ago

  • Cc steph@… added

comment:47 billerickson3 years ago

  • Cc bill.erickson@… added

comment:48 scribu3 years ago

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