Opened 2 years ago
Closed 2 years ago
#16073 closed defect (bug) (fixed)
Unsupported post formats still visible
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.1 |
| Component: | Themes | Version: | 3.1 |
| Severity: | normal | Keywords: | has-patch commit needs-testing |
| Cc: |
Description
Using the latest build (3.1 RC2), ff you add theme support for an unknown post-format it appears on the edit screen, but with a blank label.
Test with the following:
add_theme_support( 'post-formats', array( 'aside', 'gallery','bug' ) );
You will see 4 radio buttons and 3 visible labels: Standard, Aside, Gallery. The 4th label markup is there, but with no visible text.
Attachments (5)
Change History (15)
Tested and seems to work, but should this be 'patched' or should a check_post_formats function be created now for future usage.
- Milestone changed from Awaiting Review to 3.1
Maybe we can remove these at the add_theme_support level by doing a diff with get_post_format_slugs.
probably need to do something, the diff isn't taking into account options-writing.php which has a selection for the default post-format.
Suggestion then. in theme.php change the function add_theme_support to this:
function add_theme_support( $feature ) {
global $_wp_theme_features;
if ( func_num_args() == 1 )
$_wp_theme_features[$feature] = true;
else
$_wp_theme_features[$feature] = array_slice( func_get_args(), 1 );
if ( $feature == 'post-formats' )
$_wp_theme_features[$feature] = check_post_format_support($_wp_theme_features[$feature]);
}
and add this function to that file:
function check_post_format_support( $theme_post_formats ) {
$allowed_post_formats = array_keys(get_post_format_strings());
$checked_post_formats = array();
foreach ( $theme_post_formats[0] as $check_format ) {
if ( in_array ( $check_format, $allowed_post_formats ) ) {
$checked_post_formats[] = $check_format;
}
}
$return_post_formats[0]=$checked_post_formats;
return $return_post_formats;
}
Although there is almost certainly an easier way of doing it.
SergeyBiryukov — 2 years ago
comment:5
in reply to:
↑ 2
SergeyBiryukov — 2 years ago
Replying to nacin:
Maybe we can remove these at the add_theme_support level by doing a diff with get_post_format_slugs.
Done.
Replying to elfin:
Yeah much neater.
Agreed.
Tested the patch and it works nicely, both in the situation previously explained in the ticket and on options-writing.php (as mentioned by @elfin in comment 3).
comment:10
ryan — 2 years ago
- Resolution set to fixed
- Status changed from new to closed

Check to make sure the post format string exists ( != ) before adding its markup to the UI.