Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/posts/parts/cells/basic.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Posts app — the cells both modes render: the title (with its lock,
* status and reading-page badges and the Pages "View" link), the
* status and reading-page badges and the "View" link), the
* author, the date, and the expanded sub-row.
*
* @public
Expand Down Expand Up @@ -105,9 +105,9 @@ export function buildTitleCell( row: PostListItem, env: CellEnv ): HTMLElement {
titleRow.appendChild( pill( STATUS_LABELS[ row.status ] ?? row.status, statusBadgeColor( row.status ), { uppercase: true } ) );
}

// Pages: a "View" link to the public URL, in a new tab so the user
// A "View" link to the public URL, in a new tab so the user
// keeps the table state.
if ( isPages && typeof row.link === 'string' && row.link && row.status === 'publish' ) {
if ( typeof row.link === 'string' && row.link && row.status === 'publish' ) {
const view = document.createElement( 'a' );
view.href = row.link;
view.target = '_blank';
Expand Down
2 changes: 1 addition & 1 deletion apps/posts/parts/query.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function openstation_posts_window_default_query_args() {
// another user is currently editing the row, so the title cell
// can paint a small lock icon without an extra fetch.
'_fields' =>
'id,title,status,date,date_gmt,modified,modified_gmt,author,categories,tags,comment_status,excerpt,openstation_lock,_links,_embedded',
'id,title,status,date,date_gmt,modified,modified_gmt,author,categories,tags,comment_status,excerpt,openstation_lock,link,_links,_embedded',
);

/**
Expand Down
12 changes: 12 additions & 0 deletions apps/posts/posts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,18 @@ describe( 'the cells', () => {
const draft = buildTitleCell( row( 6, { status: 'draft', link: 'http://x.test/d' } ), env );
expect( pills( draft ) ).toEqual( [ 'Posts page', 'Draft' ] );
expect( draft.querySelector( 'a[target="_blank"]' ) ).toBeNull();

const postEnv = cellEnv( { extra: { mode: 'posts', editPostUrlBase: 'http://x.test/wp-admin/post.php' } } );
const publishedPost = buildTitleCell(
row( 7, {
title: { rendered: 'Published Story' },
link: 'http://x.test/published-story',
status: 'publish',
} ),
postEnv,
);
expect( publishedPost.querySelector( 'a[target="_blank"]' )?.textContent ).toBe( 'View' );
expect( publishedPost.querySelector( 'a[target="_blank"]' )?.getAttribute( 'href' ) ).toBe( 'http://x.test/published-story' );
} );

it( 'the author cell paints the name as text, and nothing for an author core could not embed', () => {
Expand Down
2 changes: 1 addition & 1 deletion docs/hooks-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -3403,7 +3403,7 @@ Default args:
```php
[
'_embed' => 'author,wp:term,wp:featuredmedia',
'_fields' => 'id,title,status,date,date_gmt,modified,modified_gmt,author,categories,tags,comment_status,excerpt,openstation_lock,_links,_embedded',
'_fields' => 'id,title,status,date,date_gmt,modified,modified_gmt,author,categories,tags,comment_status,excerpt,openstation_lock,link,_links,_embedded',
]
```

Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/postsApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function test_default_query_args_include_embed_and_fields() {
$this->assertStringContainsString( 'author', $args['_embed'] );
$this->assertStringContainsString( 'wp:term', $args['_embed'] );
$this->assertStringContainsString( 'wp:featuredmedia', $args['_embed'] );
foreach ( array( 'title', 'status', 'date', 'openstation_lock', '_embedded' ) as $field ) {
foreach ( array( 'title', 'status', 'date', 'openstation_lock', 'link', '_embedded' ) as $field ) {
$this->assertStringContainsString( $field, $args['_fields'] );
}
}
Expand Down
Loading