Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lancewillett/43970499eef7236d48ab to your computer and use it in GitHub Desktop.
Save lancewillett/43970499eef7236d48ab to your computer and use it in GitHub Desktop.
diff --git a/json-endpoints/class.wpcom-json-api-get-site-endpoint.php b/json-endpoints/class.wpcom-json-api-get-site-endpoint.php
index e6f589f..1a259d3 100644
--- a/json-endpoints/class.wpcom-json-api-get-site-endpoint.php
+++ b/json-endpoints/class.wpcom-json-api-get-site-endpoint.php
@@ -444,19 +444,24 @@ class WPCOM_JSON_API_List_Post_Formats_Endpoint extends WPCOM_JSON_API_Endpoint
$this->load_theme_functions();
}
- // Get a list of supported post formats.
- $all_formats = get_post_format_strings();
- $supported = get_theme_support( 'post-formats' );
+ $args = array(
+ 'child_of' => 0,
+ 'exclude' => '',
+ 'hide_empty' => false,
+ 'hierarchical' => 0,
+ 'order' => 'ASC',
+ 'orderby' => 'name',
+ 'pad_counts' => false,
+ );
- $supported_formats = $response['formats'] = array();
+ $terms = get_terms( 'post_format', $args );
+ $formats = array();
- if ( isset( $supported[0] ) ) {
- foreach ( $supported[0] as $format ) {
- $supported_formats[ $format ] = $all_formats[ $format ];
- }
+ foreach ( $terms as $format ) {
+ $formats[$format->term_id] = $format->name;
}
- $response['formats'] = (object) $supported_formats;
+ $response['formats'] = $formats;
return $response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment