diff --git a/includes/class-opml.php b/includes/class-opml.php
index 20382d0..b089b62 100644
--- a/includes/class-opml.php
+++ b/includes/class-opml.php
@@ -354,7 +354,7 @@ private static function group_name( $group ) {
* @param string $page_title Title of the page, see title().
* @return string Title.
*/
- private static function group_title( $group, $page_title ) {
+ public static function group_title( $group, $page_title ) {
/* translators: 1: name of the blogroll, 2: page title with author */
return \sprintf( \__( '%1$s (%2$s)', 'blockroll' ), self::group_name( $group ), $page_title );
}
@@ -392,7 +392,7 @@ public static function for_post( $post, $anchor = '' ) {
}
/**
- * Print the directory OPML listing every blogroll page's own OPML.
+ * Print the directory OPML listing each listed blogroll's OPML.
*
* @param \WP_Post[]|null $posts Blogroll posts, or null to look them up.
*/
diff --git a/templates/opml-directory.php b/templates/opml-directory.php
index 1e090ad..93bbc69 100644
--- a/templates/opml-directory.php
+++ b/templates/opml-directory.php
@@ -1,6 +1,6 @@
-
+
+
+
diff --git a/tests/test-opml.php b/tests/test-opml.php
index afa214e..0119e76 100644
--- a/tests/test-opml.php
+++ b/tests/test-opml.php
@@ -387,6 +387,37 @@ public function test_singular_without_block_has_no_discovery_link() {
const TWO_ANCHORED_BLOCKS = '';
+ public function test_directory_lists_individual_blogrolls_instead_of_the_page_file() {
+ $post = self::factory()->post->create_and_get( array( 'post_content' => self::TWO_ANCHORED_BLOCKS ) );
+ ob_start();
+ \Blockroll\Opml::directory();
+ $doc = new SimpleXMLElement( ob_get_clean() );
+
+ $this->assertCount( 2, $doc->body->outline );
+ foreach ( array(
+ 'blogs' => 'Blogs',
+ 'podcasts' => 'Podcasts',
+ ) as $anchor => $name ) {
+ $outline = $doc->body->outline[ 'blogs' === $anchor ? 0 : 1 ];
+ $this->assertSame( 'include', (string) $outline['type'] );
+ $this->assertSame( \Blockroll\Opml::opml_url( $post, $anchor ), (string) $outline['url'] );
+ $this->assertStringStartsWith( $name . ' (', (string) $outline['text'] );
+ $this->assertStringContainsString( \Blockroll\Opml::title( $post ), (string) $outline['text'] );
+ }
+ }
+
+ public function test_directory_derives_missing_anchors_and_excludes_unlisted_blogrolls() {
+ $content = self::TWO_NAMED_BLOCKS . self::OWN_ONLY;
+ $post = self::factory()->post->create_and_get( array( 'post_content' => $content ) );
+ ob_start();
+ \Blockroll\Opml::directory();
+ $doc = new SimpleXMLElement( ob_get_clean() );
+
+ $this->assertCount( 2, $doc->body->outline );
+ $this->assertSame( \Blockroll\Opml::opml_url( $post, 'blogs' ), (string) $doc->body->outline[0]['url'] );
+ $this->assertSame( \Blockroll\Opml::opml_url( $post, 'podcasts' ), (string) $doc->body->outline[1]['url'] );
+ }
+
public function test_all_groups_keeps_the_anchor_and_derives_a_missing_one() {
$post = self::factory()->post->create_and_get( array( 'post_content' => self::TWO_ANCHORED_BLOCKS ) );
$groups = \Blockroll\Opml::all_groups( $post );