Make WordPress Core

Opened 3 years ago

Last modified 7 weeks ago

#21941 new enhancement

Remove get_post_format_slugs()

Reported by: F J Kaiser Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version:
Component: Post Formats Keywords: 2nd-opinion has-patch
Focuses: Cc:


I just encountered the get_post_format_slugs() function, which is basically just wrapping get_post_format_strings() and setting the strings as keys too. So its output is an assoc array where the keys equal the values.

The three times core calls it, it does it the following:

// ~/wp-includes/posts.php -> set_post_format()
if ( 'standard' == $format || !in_array( $format, array_keys( get_post_format_slugs() ) ) )

// ~/wp-includes/posts.php -> _post_format_request()
$slugs = get_post_format_slugs();
if ( isset( $slugs[ $qvs['post_format'] ] ) )
	$qvs['post_format'] = 'post-format-' . $slugs[ $qvs['post_format'] ];

// ~/wp-includes/theme.php -> add_theme_support()
switch ( $feature ) {
	case 'post-formats' :
		if ( is_array( $args[0] ) )
			$args[0] = array_intersect( $args[0], array_keys( get_post_format_slugs() ) );

So in every case it would've been enough to simply call get_post_format_strings().

Do we really need this function?

Attachments (2)

21941.diff (1.8 KB) - added by MikeHansenMe 13 months ago.
first pass.
21941.2.diff (1.8 KB) - added by MikeHansenMe 7 weeks ago.

Download all attachments as: .zip

Change History (6)

#1 @F J Kaiser
3 years ago

  • Severity changed from normal to minor

#2 @nacin
23 months ago

  • Component changed from General to Post Formats

13 months ago

first pass.

#3 @MikeHansenMe
13 months ago

  • Keywords has-patch needs-unit-tests added

7 weeks ago

#4 @MikeHansenMe
7 weeks ago

  • Keywords needs-unit-tests removed

21941.2.diff is a refresh. It looks like we now have tests for add_theme_support() and set_post_format(). I think these tests cover all the usage of get_post_format_slugs.

Note: See TracTickets for help on using tickets.