Skip to content

Commit a9aaeda

Browse files
dshanskesnarfed
authored andcommitted
Add support for querying categories
1 parent df94038 commit a9aaeda

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

micropub.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,12 @@ private static function query_handler( $user_id ) {
368368
$syndicate_tos = apply_filters( 'micropub_syndicate-to', array(), $user_id );
369369
$resp = array( 'syndicate-to' => $syndicate_tos );
370370
break;
371+
case 'category':
372+
$resp = array_merge(
373+
get_tags( array( 'fields' => 'names' ) ),
374+
get_terms( array( 'taxonomy' => 'category', 'fields' => 'names' ) )
375+
);
376+
break;
371377
case 'source':
372378
$post_id = url_to_postid( static::$input['url'] );
373379
if ( ! $post_id ) {

tests/test_micropub.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,18 @@ function test_query_source() {
293293
$this->check( 200, self::$mf2 );
294294
}
295295

296+
function test_query_category() {
297+
$_POST = self::$post;
298+
$post = $this->check_create();
299+
$_GET = array(
300+
'q' => 'category'
301+
);
302+
wp_set_post_tags( $post->ID, 'Tag' );
303+
wp_create_categories( array( 'Category' ), $post->ID );
304+
$this->check( 200, array( 'Tag', 'Category' ) );
305+
}
306+
307+
296308
function test_query_source_with_properties() {
297309
$_POST = self::$post;
298310
$post = $this->check_create();

0 commit comments

Comments
 (0)