Skip to content

Commit 688a155

Browse files
committed
Limit post formats to those supported by theme
1 parent 56b0c59 commit 688a155

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

includes/adapters/class-friends.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,30 @@ public function get_channels( $channels, $user_id ) {
176176
}
177177

178178
/**
179-
* Get post formats supported by Friends plugin.
179+
* Get post formats supported by the current theme.
180180
*
181181
* @return array Associative array of format slug => format name.
182182
*/
183183
protected function get_post_formats() {
184-
// Use WordPress core format strings with 'standard' added.
184+
// Standard is always available.
185185
$formats = array( 'standard' => \__( 'Standard', 'microsub' ) );
186186

187-
return \array_merge( $formats, \get_post_format_strings() );
187+
// Get formats supported by the theme.
188+
$theme_formats = \get_theme_support( 'post-formats' );
189+
190+
if ( empty( $theme_formats ) || empty( $theme_formats[0] ) ) {
191+
return $formats;
192+
}
193+
194+
$all_formats = \get_post_format_strings();
195+
196+
foreach ( $theme_formats[0] as $format ) {
197+
if ( isset( $all_formats[ $format ] ) ) {
198+
$formats[ $format ] = $all_formats[ $format ];
199+
}
200+
}
201+
202+
return $formats;
188203
}
189204

190205
/**

0 commit comments

Comments
 (0)