Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Latest comment admin imports #8085

Merged
merged 3 commits into from
Jul 23, 2018
Merged

fix: Latest comment admin imports #8085

merged 3 commits into from
Jul 23, 2018

Conversation

tofumatt
Copy link
Member

@tofumatt tofumatt commented Jul 20, 2018

This is a fix to the latest comments block from #7941; apparently importing that admin file didn't work super-well and caused errors when re-generating fixtures, etc.

The function we're using is trivial to re-implement and I think the best solution for now. It also let me regenerate the fixtures.

@tofumatt tofumatt requested review from aduth and removed request for aduth July 20, 2018 14:36
@tofumatt tofumatt force-pushed the fix/latest-comments branch from 08975fd to 0e30658 Compare July 20, 2018 15:04
@tofumatt tofumatt requested a review from aduth July 20, 2018 15:04
function gutenberg_draft_or_post_title( $post = 0 ) {
$title = get_the_title( $post );
if ( empty( $title ) ) {
$title = __( '(no title)' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Text domain is missing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be __( '(no title)', 'gutenberg' );, right? 😄

@tofumatt tofumatt requested a review from a team July 20, 2018 15:34
@Soean Soean mentioned this pull request Jul 23, 2018
4 tasks
@pento
Copy link
Member

pento commented Jul 23, 2018

@tofumatt: Is there any particular reason for using _draft_or_post_title(), apart from the obvious?

It seems that Core has had the behaviour of not displaying a title since forever, with no bug reports, which kind of makes sense: if a CPT doesn't allow a post_title, there's a good chance it probably doesn't do comments and the Recent Comment widget, either.

@tofumatt
Copy link
Member Author

tofumatt commented Jul 23, 2018 via email

@aduth
Copy link
Member

aduth commented Jul 23, 2018

It can be done separately, but I found we could have slightly-improved support for WordPress functions via the SHORTINIT constant, which could make some of our ad-hoc require in bin/get-server-blocks.php redundant (i.e. require ABSPATH . 'wp-settings.php';).

https://github.com/WordPress/wordpress-develop/blob/796bac86451a4fb626b298181c9ac1f37bc6c441/src/wp-settings.php#L133-L136

(Still wouldn't have fixed the original issue on its own, though)

@aduth
Copy link
Member

aduth commented Jul 23, 2018

In general, I think we should want to encourage avoiding dependency on wp-admin files within block implementations (since they're expected to be run in non-wp-admin contexts).

* Copied from `wp-admin/includes/template.php`, but we can't include that
* because:
*
* 1. it causes bugs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be more specific here.

* because:
*
* 1. it causes bugs
* 2. it's in the admin; ideally we *shouldn't*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete sentence?

@tofumatt tofumatt merged commit 3d24583 into master Jul 23, 2018
@tofumatt tofumatt deleted the fix/latest-comments branch July 23, 2018 16:57
@tofumatt tofumatt added this to the 3.4 milestone Jul 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants