WordPress.org

Make WordPress Core

Opened 8 years ago

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

Download all attachments as: .zip

Change History (61)

#1 follow-up: @mtekk
8 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.

@hakre
8 years ago

First patch for template.php

@hakre
8 years ago

first demo plugin

@hakre
8 years ago

Demo Plugin v0.1

#2 in reply to: ↑ 1 @hakre
8 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.

@hakre
8 years ago

Test Plugin v0.2 for the next Patchset

@hakre
8 years ago

Fully Patched.

#3 @hakre
8 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.

#4 @hakre
8 years ago

ie7 test passed.

#5 @hakre
8 years ago

see also (dup): #9605

#6 @hakre
8 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.

#7 @hakre
8 years ago

  • Keywords second-opinion added

#8 @hakre
8 years ago

  • Keywords developer-feedback added

#9 @hakre
8 years ago

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

#10 @Denis-de-Bernardy
8 years ago

In the latest patch, shouldn't:

screen-metas-link-wrap {

be a class or an ID instead?

#11 @Denis-de-Bernardy
8 years ago

  • Keywords dev-feedback added; developer-feedback removed

#12 @Denis-de-Bernardy
8 years ago

  • Keywords 2nd-opinion removed

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

#13 @hakre
8 years ago

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

@hakre
8 years ago

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

#14 @hakre
8 years ago

  • Keywords 2nd-opinion added

#15 @Denis-de-Bernardy
8 years ago

  • Keywords tested added; dev-feedback removed

patch doesn't break anything

#16 @Denis-de-Bernardy
8 years ago

  • Milestone changed from 2.8 to Future Release

patch is b0rke

@hakre
8 years ago

deb0rked

@hakre
8 years ago

Minor Testplugin update (Naming)

#17 @hakre
8 years ago

  • Milestone changed from Future Release to 2.8

Patch updated to latest revision.

#18 @Denis-de-Bernardy
8 years ago

any interest, or shall we punt?

#19 @Denis-de-Bernardy
8 years ago

  • Keywords dev-feedback added

#20 @hakre
8 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.

@hakre
8 years ago

Example Implementation Screenshot (Closed)

@hakre
8 years ago

Example Implementation Screenshot (Opened)

#21 @Denis-de-Bernardy
8 years ago

  • Keywords early added
  • Milestone changed from 2.8 to 2.9

no apparent interest...

#22 @hakre
8 years ago

That's a pitty.

@Denis-de-Bernardy
7 years ago

patch is by arena

#23 follow-up: @Denis-de-Bernardy
7 years ago

added another potential patch by arena

#24 in reply to: ↑ 23 @arena
7 years ago

Replying to Denis-de-Bernardy:

added another potential patch by arena

Merci !

#25 @Denis-de-Bernardy
7 years ago

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

@alexkingorg
7 years ago

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

#26 @hakre
7 years ago

@alexkingorg: please see file 9657.patch

#27 @JohnLamansky
7 years ago

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

+1

#28 @ryan
7 years ago

  • Milestone changed from 2.9 to Future Release

#29 @hakre
7 years ago

  • Version changed from 2.8 to 3.0

Related: #1151

#30 @hakre
7 years ago

Related: #11517

#31 @hakre
7 years ago

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

#32 @ptahdunbar
7 years ago

what's the status on the patch?

#33 @voyagerfan5761
7 years ago

  • Cc WordPress@… added

#34 @jane
7 years ago

Plugin authors should be able to add tabs.

#35 @rspindel
7 years ago

  • Cc rspindel added

#37 @mikeschinkel
6 years ago

  • Cc mikeschinkel@… added

#38 @ptahdunbar
6 years ago

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

#39 @ptahdunbar
6 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 @hakre
6 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

@ptahdunbar
6 years ago

first pass for proper screen meta API

#41 @ptahdunbar
6 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 6 years ago by ptahdunbar (previous) (diff)

#42 @scribu
6 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.

#43 @scribu
6 years ago

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

@ptahdunbar
6 years ago

second pass for screen meta api. bug fixes and improvements

#44 @ptahdunbar
6 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
}

#45 @westi
6 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

#46 @sillybean
5 years ago

  • Cc steph@… added

#47 @billerickson
5 years ago

  • Cc bill.erickson@… added

#48 @scribu
5 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.