Make WordPress Core

Opened 16 years ago

Closed 16 years ago

#9606 closed feature request (fixed)

screen_layout for plugins

Reported by: arena's profile arena Owned by: arena's profile arena
Milestone: 2.8 Priority: high
Severity: normal Version: 2.8
Component: Administration Keywords: has-patch tested commit
Focuses: Cc:

Description

In order to allow plugins to integrate this new wp feature !

function screen_layout($screen) {
	global $screen_layout_columns;

	switch ( $screen ) {
		case 'dashboard':
			$screen_layout_columns = get_user_option('screen_layout_dashboard');
			$num = 4;
			break;
		case 'post':
			$screen_layout_columns = get_user_option('screen_layout_post');
			$num = 2;
			break;
		case 'page':
			$screen_layout_columns = get_user_option('screen_layout_page');
			$num = 2;
			break;
		case 'link':
			$screen_layout_columns = get_user_option('screen_layout_link');
			$num = 2;
			break;
		default:
			$screen_layout_columns = 0;
			return '';
	}

// the following test is useless !
	if ( ! $screen_layout_columns )
			$screen_layout_columns = 2;

	$i = 1;

to be replaced by

function screen_layout($screen) {
	global $screen_layout_columns;

	$wp_screen_layouts = array('dashboard' => 4, 'post' => 2, 'page' => 2, 'link' => 2);

	$wp_screen_layouts = apply_filters('screen_layout', $wp_screen_layouts, $screen);

	if (!isset($wp_screen_layouts[$screen])) {
		$screen_layout_columns = 0;
		return '';
	}

	$screen_layout_columns = get_user_option("screen_layout_$screen");
	$num = $wp_screen_layouts[$screen];

	$i = 1;

Attachments (2)

screen_layout.diff (1.4 KB) - added by arena 16 years ago.
9606.diff (1.2 KB) - added by arena 16 years ago.

Download all attachments as: .zip

Change History (17)

@arena
16 years ago

#1 @arena
16 years ago

  • Owner changed from anonymous to arena

#2 @arena
16 years ago

  • Keywords needs-testing added
  • Priority changed from normal to high

#3 @arena
16 years ago

  • Version set to 2.8

#4 @Denis-de-Bernardy
16 years ago

  • Keywords tested added; needs-testing removed

#5 @azaozz
16 years ago

This heavily depends on js and the actual html of the pages, don't think plugins would be able to use it other than disabling it when the user wants to switch number of columns. Don't think that's needed.

#6 follow-up: @Denis-de-Bernardy
16 years ago

unless you build an editor for a different data type and write the needed scripts.

#7 in reply to: ↑ 6 ; follow-ups: @azaozz
16 years ago

Replying to Denis-de-Bernardy:

unless you build an editor for a different data type and write the needed scripts.

In this case the page would be mostly copied from the write posts page? Can probably use the same columns setting too.

Actually the different settings for posts and pages should probably be merged too, don't see a used case where one would need 2 columns and the other only one as both screens are almost identical.

The patch also wouldn't work if the user_option is not set (the "useless" check does exactly that).

#8 in reply to: ↑ 7 @Denis-de-Bernardy
16 years ago

Replying to azaozz:

Actually the different settings for posts and pages should probably be merged too, don't see a used case where one would need 2 columns and the other only one as both screens are almost identical.

it depends on his prefs. suppose a user sticks to the default layout on posts (which are short), and moves all of the widgets to the right into the middle column on pages, to have a wider editor.

#9 in reply to: ↑ 7 ; follow-up: @arena
16 years ago

Replying to azaozz:

Replying to Denis-de-Bernardy:

unless you build an editor for a different data type and write the needed scripts.

In this case the page would be mostly copied from the write posts page? Can probably use the same columns setting too.

Actually the different settings for posts and pages should probably be merged too, don't see a used case where one would need 2 columns and the other only one as both screens are almost identical.

The patch also wouldn't work if the user_option is not set (the "useless" check does exactly that).

(the "useless" check does exactly that).

sorry if i follow the code, in the switch, if the $screen is not found => return
so in the test :

if ( ! $screen_layout_columns )

$screen_layout_columns is always true...

#10 in reply to: ↑ 9 @azaozz
16 years ago

Replying to arena:

$screen_layout_columns is always true...

Unless the $screen is found but the option is not set. Then $screen_layout_columns = false so it needs default value which is 2. See get_user_option()

#11 @arena
16 years ago

true !

@arena
16 years ago

#12 @arena
16 years ago

  • Keywords needs-testing added; tested removed

Patch fixing the test if get_user_option not found

Some plugins have a design similar to the wordpress admin pages and relying on settings from other admin pages looks tricky !

#13 @ShaneF
16 years ago

  • Keywords commit added; needs-testing removed

Again.. looks good. No error this time around.

#14 @Denis-de-Bernardy
16 years ago

  • Keywords tested added

#15 @azaozz
16 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [11144]) Let plugins use screen layout columns, props arena, fixes #9606

Note: See TracTickets for help on using tickets.