-
Notifications
You must be signed in to change notification settings - Fork 10.7k
TT3 compatibility #35306
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
TT3 compatibility #35306
Conversation
In themes like 2023 where foreground and background is undefined, this assignes incorrect colors.
|
cc @Aljullu please let me know if you think these styles for blocks are needed for TT3 (code from the bottom of styling for TT2): |
New hook, template, or database changes in this PRTemplate changes:
|
Test Results SummaryCommit SHA: 606071c
To view the full API test report, click here. To view the full E2E test report, click here. To view all test reports, visit the WooCommerce Test Reports Dashboard. |
|
I checked the E2E tests and they seem to work fine in manual testing. I tested with TT3 and 2019 theme (as it looks like that's what is used in the e2e tests). The code sniff is highlighting problems with many files that have undocumented hooks and I don't really think it makes sense to document the 350 highlighted hooks in this PR. |
Aljullu
left a comment
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 working on this, @peterfabian!
I did an initial review. I didn't finish it yet, but leaving some early feedback for now.
cc @Aljullu please let me know if you think these styles for blocks are needed for TT3 (code from the bottom of styling for TT2):
It should be possible to remove everything under .wc-block-product-search because in WP 6.1 the Product Search block will be replaced with a GB Search block variation (woocommerce/woocommerce-blocks#6191), so we already inherit all styling from the GB block.
Regarding the .wp-block-search rules, they impact the GB Search block (and the new Product Search variation). I would personally remove them, because I don't think it's WC's job to style that block.
| $wp_button_class = wc_wp_theme_get_element_class_name( 'button' ) ? ' ' . wc_wp_theme_get_element_class_name( 'button' ) : ''; | ||
| echo '<a href="' . esc_url( wc_get_checkout_url() ) . '" class="button checkout wc-forward' . esc_attr( $wp_button_class ) . '">' . esc_html__( 'Checkout', 'woocommerce' ) . '</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.
I see this pattern repeated in several places, wondering if we could use trim() to simplify the code. Something along these lines:
| $wp_button_class = wc_wp_theme_get_element_class_name( 'button' ) ? ' ' . wc_wp_theme_get_element_class_name( 'button' ) : ''; | |
| echo '<a href="' . esc_url( wc_get_checkout_url() ) . '" class="button checkout wc-forward' . esc_attr( $wp_button_class ) . '">' . esc_html__( 'Checkout', 'woocommerce' ) . '</a>'; | |
| echo '<a href="' . esc_url( wc_get_checkout_url() ) . '" class="button checkout wc-forward' . esc_attr( trim( ' ' . wc_wp_theme_get_element_class_name( 'button' ) ) ) . '">' . esc_html__( 'Checkout', 'woocommerce' ) . '</a>'; |
Not sure if the code is much clearer, thought. 😅 So just leaving the suggestion here, but I don't have a strong preference anyway.
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! I was also slightly bothered by it, so was thinking about whether I should make a function out of it. The usage of trim is a nice trick.
| if ( ! empty( $actions ) ) { | ||
| foreach ( $actions as $key => $action ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited | ||
| echo '<a href="' . esc_url( $action['url'] ) . '" class="woocommerce-button button ' . sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . '</a>'; | ||
| echo '<a href="' . esc_url( $action['url'] ) . '" class="woocommerce-button' . esc_attr( $wp_button_class ) . ' button ' . sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . '</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.
Just to confirm, since I'm not used to this codebase. We are inheriting $wp_button_class from a parent template? Because $wp_button_class is not declared in this file.
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.
Yup, it's defined over here: https://github.com/woocommerce/woocommerce/pull/35306/files#diff-d49488c34017d273db858b7b6eff58f22d95310991d26638e75793c6a1e98678R3213
The echo here is inside 2 foreach loops in the template, so didn't want to evaluate it each time, and we also want to make templates as dumb as possible, so having conditions and other code outside of them unless necessary. Which makes me think I should also remove the other conditionals from templates 🤔
| /** | ||
| * Twenty Twenty-Three support. | ||
| * | ||
| * @since 7.0.2 |
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.
In many places we specify @version 7.1.0, I guess this will need to be unified once we know whether that's included in a patch release?
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.
Yup, I'll search and replace it once we figure it out. Good point.
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.
Fixed in f543cc0
Updated in |
But this only goes so far. If e.g. the translation is longer, it will look weird anyway.
|
This should be fixed now as well. |
Fixed in 2742331 |
|
Hi @peterfabian, thanks for merging this pull request. Please take a look at these follow-up tasks you may need to perform:
|
* TT3 compatibility (#35306) * Prep for cherry pick 35306 Co-authored-by: Peter Fabian <[email protected]> Co-authored-by: WooCommerce Bot <[email protected]>
* TT3 compatibility (#35306) * Prep for cherry pick 35306 Co-authored-by: Peter Fabian <[email protected]> Co-authored-by: WooCommerce Bot <[email protected]>
| ?> | ||
|
|
||
| <button type="submit" name="add-to-cart" value="<?php echo esc_attr( $product->get_id() ); ?>" class="single_add_to_cart_button button alt"><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button> | ||
| <button type="submit" name="add-to-cart" value="<?php echo esc_attr( $product->get_id() ); ?>" class="single_add_to_cart_button button alt<?php echo esc_attr( wc_wp_theme_get_element_class_name( 'button' ) ? ' ' . wc_wp_theme_get_element_class_name( 'button' ) : '' ); ?>"><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button> |
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.
@peterfabian is there a need to call wc_wp_theme_get_element_class_name( 'button' ) twice? Could this be
<?php echo esc_attr( wc_wp_theme_get_element_class_name( 'button' ) ); ?>
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.
@helgatheviking It would need a leading space but that could be added after alt.
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.
Gotcha. Seems like worse case is there's a trailing space if you remove the duplication... class="single_add_to_cart_button button alt ">



All Submissions:
Changes proposed in this Pull Request:
This work builds on the great cleanup done by Rubik/Kirigami earlier this year. I did a tiny cleanup of colors from blocktheme.scss, where I moved the unnecessary definitions to TT2 theme's CSS to retain the same styling for TT2.
Besides, did a quick analysis and comparison for all CSS rules and added the relevant ones from TT2 styling to TT3. Added also the WP class to buttons to enable all the style definitions that come with WP 6.1 and TT3.
Layout-wise, it's very similar to TT2. The colors got tricky here and there as some styles have effectively only 2 colors while some define 5 distinct colors, but I tried to make it work for all styles.
Style colors overview:

How to test the changes in this Pull Request:
Other information:
pnpm changelog add --filter=<project>?FOR PR REVIEWER ONLY: