-
Notifications
You must be signed in to change notification settings - Fork 6
Conversation
Started adding theme integration Maybe |
Header And Footer Templates Hi @miina,
That's a good idea. Separate issues and PRs for And we could merge the templates into |
templates/footer-search.php
Outdated
|
||
?> | ||
<!-- Search --> | ||
<section class='travel-search py4 xs-hide sm-hide relative'> |
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.
This isn't a blocker, but it'd be nice to have double quotes in the template. We can go back and address this after the demo on Thursday.
$reviews = wp_count_comments( get_the_ID() ); | ||
?> | ||
<?php /* translators: %d: Number of reviews. */ ?> | ||
<p class="travel-results-result-subtext"><?php echo sprintf( esc_html__( '%d Reviews', 'travel' ), esc_html( $reviews->approved ) ); ?></p> |
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.
This could be printf()
instead of echo sprintf()
.
templates/entry/meta/rating.php
Outdated
?> | ||
<div class="relative h2 line-height-2 mb1"> | ||
<div class="travel-results-result-stars green"> | ||
<?php for ( $i = 0; $i < $rating; $i++ ) : ?> |
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.
How about something like:
echo esc_html( str_repeat( '*', $rating ) );
templates/footer-search.php
Outdated
<!-- Search --> | ||
<section class='travel-search py4 xs-hide sm-hide relative'> | ||
<div class='px1 md-px2 pb1 relative'> | ||
<h3 class='travel-search-heading travel-spacing-none h1 bold mb2 center'><?php esc_html_e( 'Have a specific destination in mind?' ); ?></h3> |
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.
Could this include the text domain of 'travel'
, and likewise for the other translation functions in the file?
esc_html_e( 'Have a specific destination in mind?', 'travel' )
templates/entry/full.php
Outdated
<option value="1"><?php esc_html_e( 'For 1' ); ?></option> | ||
<?php for ( $i = 2; $i <= 8; $i += 2 ) : ?> | ||
<?php /* translators: %d: The number of people */ ?> | ||
<option value="<?php echo esc_attr( $i ); ?>"><?php echo sprintf( esc_html__( 'For %d', 'travel' ), esc_html( $i ) ); ?></option> |
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.
This is a minor point, but this could be printf
instead of echo sprintf
.
templates/entry/full.php
Outdated
<?php endfor; ?> | ||
</select> | ||
|
||
<a href="#" class="product-cta-btn ampstart-btn rounded center bold white block col-12"><?php esc_html_e( 'Call to book' ); ?></a> |
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.
Could this please use the text domain of 'travel'
?
|
||
?> | ||
<!-- Popular --> | ||
<?php echo amp_travel_render_similar_adventures(); // WPCS: XSS ok. ?> |
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.
Thanks for creating this template tag.
* @package WPAMPTheme | ||
*/ | ||
|
||
// Ignore the issues of this file since that's just a copied HTML placeholder. |
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.
Though this footer.php
is only a placeholder, it looks good. We could work on dynamic data later, at least after the screencast this Thursday.
includes/functions.php
Outdated
<span class="travel-results-result-subtext mr1">' . | ||
/* translators: %d: The number of reviews */ | ||
sprintf( esc_html__( '%d Reviews', 'travel' ), esc_html( $comments->approved ) ) . '</span> | ||
<span class="travel-results-result-subtext"><svg class="travel-icon" viewBox="0 0 77 100"><g fill="none" fillRule="evenodd"><path stroke="currentColor" strokeWidth="7.5" d="M38.794 93.248C58.264 67.825 68 49.692 68 38.848 68 22.365 54.57 9 38 9S8 22.364 8 38.85c0 10.842 9.735 28.975 29.206 54.398a1 1 0 0 0 1.588 0z"></path><circle cx="38" cy="39" r="10" fill="currentColor"></circle></g></svg> |
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 plugin's validator raised invalid_attribute
errors forfillRule
and strokeWidth
.
Similar errors appear on copying this entire <svg>
into the AMP validator:
The attribute 'fillrule' may not appear in tag 'g'.
The attribute 'strokewidth' may not appear in tag 'path'
The page is still valid AMP, but the preprocessor stripped those attributes.
templates/entry/meta/location.php
Outdated
$location = ! empty( $locations ) ? $locations[0] : '--'; | ||
?> | ||
<p class="travel-results-result-subtext mb1"> | ||
<svg class="travel-icon" viewBox="0 0 77 100"><g fill="none" fillrule="evenodd"><path stroke="currentColor" strokewidth="7.5" d="M38.794 93.248C58.264 67.825 68 49.692 68 38.848 68 22.365 54.57 9 38 9S8 22.364 8 38.85c0 10.842 9.735 28.975 29.206 54.398a1 1 0 0 0 1.588 0z"></path><circle cx="38" cy="39" r="10" fill="currentColor"></circle></g></svg> |
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.
As mentioned, it looks like fillrule
and strokewidth
aren't allowed. The plugin's preprocessor removes them, so the page is still valid AMP. But just so we're aware that they're not appearing on the front-end.
if ( post_password_required() ) { | ||
return; | ||
} | ||
|
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.
This is outside this PR's diff, but could you please add 'comments'
to the 'adventure'
CPT 'supports'
argument? I think this is blocking the "Popular Adventures" block from displaying, as you can't add ratings (comments) to the 'adventure' post type.
includes/functions.php
Outdated
<option value="">--</option>'; | ||
|
||
for ( $i = 5; $i >= 1; $i-- ) { | ||
echo '<option value="' . esc_attr( $i ) . '">' . sprintf( '%d star(s)', esc_attr( $i ) ) . '</option>'; |
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.
This is looking good. What do you think of this small change to separate the singular and plural?
Instead of
'%d star(s)'
how about:
_n( '%d star', '%d stars', $i, 'travel' )
templates/entry/full.php
Outdated
|
||
<div class="product-cta lg-col-2 lg-right-align"> | ||
<h4 class="product-cta-title mb2 line-height-1" [text]="'$' + adventure_current_price">$<?php echo esc_html( get_post_meta( get_the_ID(), 'amp_travel_price', true ) ); ?></h4> | ||
<select class="select-arr mb1 rounded" name="count" on="change:AMP.setState({ adventure_current_price: event.value * adventure_price })"> |
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 develop branch deletes that file, so having changes in that file in this PR caused merge conflics. Please do npm run build when checking this out.
Building editor-blocks.js The Please do |
includes/functions.php
Outdated
|
||
for ( $i = 5; $i >= 1; $i-- ) { | ||
/* translators: %d: Rating */ | ||
echo '<option value="' . esc_attr( $i ) . '">' . sprintf( _n( '%d star', '%d stars', $i, 'travel' ), number_format_i18n( $i ) ) . '</option>'; |
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.
@kienstra This line is now throwing CS error:
includes/functions.php:153:67: error - All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '_n'. (WordPress.XSS.EscapeOutput.OutputNotEscaped)
.
Any thoughts how to fix that?
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.
Hi @miina, wrapping the _n()
call in esc_html()
should take care of that. Otherwise:
// WPCS: XSS ok.
@kienstra Thanks for reviewing, most of the issues should be addressed now. Left the gallery as static for now, hopefully that's OK for now and could be addressed later if needed. There's just one issue that I'm not sure how to fix, any thoughts? @mehigh Thanks for generating the HTML!
However, with the AMP plugin on it looks like the padding gets stripped and only this is left:
Would be great if you could help with that issue. |
…nto feature/36-adventure-single
It may be that number_format_i18n() needs esc_html(). WordPress.XSS.EscapeOutput.OutputNotEscaped
…nto feature/36-adventure-single
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.
Making sure we capture - related to #36. |
This is left:
And of course copying the product.css from ampstart (i've setup that repo next to this and referenced the CSS with a regular CSS link during development).
Reached 44KB of CSS until now.