-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Latest Posts: add grid option and improve front-end rendering #1992
Conversation
lib/blocks/latest-posts.php
Outdated
$post_date = "<span class='wp-block-latest-posts__post-date'>{$post_the_date}</span>"; | ||
} | ||
|
||
$posts_content .= "<li><a href='{$post_permalink}'>{$post_title}</a>{$post_date}</li>\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return value of get_permalink()
also needs to go through esc_url()
, which was missed previously.
The return values of get_the_date()
and get_the_title()
should probably also go through esc_html()
.
lib/blocks/latest-posts.php
Outdated
|
||
$posts_content .= "<li><a href='{$post_permalink}'>{$post_title}</a></li>\n"; | ||
if ( $attributes['displayPostDate'] ) { | ||
$post_date = "<span class='wp-block-latest-posts__post-date'>{$post_the_date}</span>"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not a <time datetime='...'>
element be used here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sounds like a good update.
lib/blocks/latest-posts.php
Outdated
} | ||
|
||
$class = 'wp-block-latest-posts ' . esc_attr( 'align' . $align ); | ||
if ( $attributes['layout'] === 'grid' ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs condition condition.
@melchoyce see #1991 |
…trs added camelCasing
534ae27
to
11522a0
Compare
Rebased to include fix from show-count fix from |
Should we prevent flexbox from wrapping entirely until we add support for column counts? How would we know to have a fixed width for a given post in the grid if we don't know the number of columns we intend to show? |
We should get the date format to match (doesn't have to be here). |
It would be good to use _wpDateSettings.formats.date at some point.
Updated date format. It'd be nice to use |
@mtias Could we try limiting the grid to either two or three columns in a future PR? |
I was thinking of adding the column slider. I can see cases where it makes sense to have many in a line, specially if you use the full-width option. |
Okay, I was thinking just short-term — but it sounds like you're planning on implementing the columns sooner rather than later? |
Added issue for exporting PHP |
This enhances the latest posts block adding a "grid" layout option.
In the future, we'd want to add a columns slider like galleries have.
The front-end rendering seemed quite lackluster and wasn't rendering the date. This also fixes that.