Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#38327 closed defect (bug) (fixed)

Inline docs indicate wp_default_editor filter accepts an array but it actually filters a string

Reported by: goto10's profile goto10 Owned by: johnbillion's profile johnbillion
Milestone: 4.7 Priority: normal
Severity: normal Version: 3.9
Component: Editor Keywords:
Focuses: docs Cc:

Description

Looking at wp_default_editor() inside general-template.php, the wp_default_editor filter takes the string $r (which is either 'tinymce', 'html', or 'test'), but the inline docs suggest that an array is being filtered.

/**
 * Find out which editor should be displayed by default.
 *
 * Works out which of the two editors to display as the current editor for a
 * user. The 'html' setting is for the "Text" editor tab.
 *
 * @since 2.5.0
 *
 * @return string Either 'tinymce', or 'html', or 'test'
 */
function wp_default_editor() {
	$r = user_can_richedit() ? 'tinymce' : 'html'; // defaults
	if ( wp_get_current_user() ) { // look for cookie
		$ed = get_user_setting('editor', 'tinymce');
		$r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r;
	}

	/**
	 * Filters which editor should be displayed by default.
	 *
	 * @since 2.5.0
	 *
	 * @param array $r An array of editors. Accepts 'tinymce', 'html', 'test'.
	 */
	return apply_filters( 'wp_default_editor', $r );
}

Change History (5)

#1 @goto10
8 years ago

  • Version changed from 4.6.1 to 3.9

#2 @johnbillion
8 years ago

  • Focuses docs added
  • Milestone changed from Awaiting Review to 4.7

#3 follow-up: @johnbillion
8 years ago

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

In 39074:

Editor: Correct the description of the parameter passed to the wp_default_editor filter.

Props goto10
Fixes #38327

#4 in reply to: ↑ 3 @dimadin
8 years ago

@johnbillion You added stringtwice.

#5 @johnbillion
8 years ago

In 39139:

Editor: Correct the docblock for the wp_default_editor filter.

Props dimadin
See #38327

Note: See TracTickets for help on using tickets.