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

Try applying notice classes with JS templates #5225

Closed
wants to merge 11 commits into from
Closed

Try applying notice classes with JS templates #5225

wants to merge 11 commits into from

Conversation

joedolson
Copy link
Contributor

  • Uses echo wp_get_admin_notice() because wp_kses_post removes template conditionals
  • Adds function to output data because there are two usages in theme-install.php and the only difference is the notice class.
  • Function will be easier to clone for use in other similar contexts.

Tested and works. Currently loses the padding in the error messages due to missing p wrapper; todo.

image

Trac ticket: https://core.trac.wordpress.org/ticket/57791


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

- Uses echo wp_get_admin_notice() because wp_kses_post removes template conditionals
- Adds function to output data because there are two usages in theme-install.php  and the only difference is the notice class.
- Function will be easier to clone for use in other similar contexts.
Copy link
Contributor

@costdev costdev left a comment

Choose a reason for hiding this comment

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

Mostly looks good @joedolson! I hadn't gotten a chance to follow up on this so thanks for continuing work here!

Just left a few queries, and some alignment corrections.

* @type string $requires_php The version of PHP which the plugin requires.
* }
*/
$compatibility_notice . do_action( "in_plugin_update_message-{$file}", $plugin_data, $response ), // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores,
Copy link
Contributor

Choose a reason for hiding this comment

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

Since do_action() returns void, this appends null (or '') to the notice. While this doesn't present an issue for the message, I wonder if we should just call do_action() above the wp_admin_notice() call?

* @type string $package Theme update package URL.
* }
*/
$compatibility_notice . do_action( "in_theme_update_message-{$theme_key}", $theme, $response ), // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
Copy link
Contributor

Choose a reason for hiding this comment

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

Same query as above

</p></div>
<?php
$compatibility_template = theme_compatibility_template();
echo wp_get_admin_notice(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this used instead of wp_admin_notice() because of escaping issues? If so, we might consider adding an inline comment to ensure this doesn't get changed in future without awareness of possible escaping issues.

Comment on lines +834 to +835
'type' => 'warning',
'additional_classes' => array( 'update-message', 'inline', 'notice-alt' ),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
'type' => 'warning',
'additional_classes' => array( 'update-message', 'inline', 'notice-alt' ),
'type' => 'warning',
'additional_classes' => array( 'update-message', 'inline', 'notice-alt' ),
Comment on lines +1012 to +1014
$no_customizer_support = __( 'This theme doesn\'t support Customizer.' );
$no_customizer_support .= '<# if ( data.actions.activate ) { #>';
$no_customizer_support .= sprintf(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$no_customizer_support = __( 'This theme doesn\'t support Customizer.' );
$no_customizer_support .= '<# if ( data.actions.activate ) { #>';
$no_customizer_support .= sprintf(
$no_customizer_support = __( 'This theme doesn\'t support Customizer.' );
$no_customizer_support .= '<# if ( data.actions.activate ) { #>';
$no_customizer_support .= sprintf(
Comment on lines +971 to +973
'type' => 'error',
'additional_classes' => array( 'notice-alt', 'notice-large' ),
'attributes' => array(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
'type' => 'error',
'additional_classes' => array( 'notice-alt', 'notice-large' ),
'attributes' => array(
'type' => 'error',
'additional_classes' => array( 'notice-alt', 'notice-large' ),
'attributes' => array(
Comment on lines +912 to +913
$update_incompatible = '<h3 class="notice-title">' . __( 'Update Incompatible' ) . '</h3><p><# if ( ! data.updateResponse.compatibleWP && ! data.updateResponse.compatiblePHP ) { #>';
$update_incompatible .= sprintf(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$update_incompatible = '<h3 class="notice-title">' . __( 'Update Incompatible' ) . '</h3><p><# if ( ! data.updateResponse.compatibleWP && ! data.updateResponse.compatiblePHP ) { #>';
$update_incompatible .= sprintf(
$update_incompatible = '<h3 class="notice-title">' . __( 'Update Incompatible' ) . '</h3><p><# if ( ! data.updateResponse.compatibleWP && ! data.updateResponse.compatiblePHP ) { #>';
$update_incompatible .= sprintf(
);
$update_incompatible .= wp_update_php_annotation( '</p><p><em>', '</em>', false );
}
$update_incompatible .= '<# } else if ( ! data.updateResponse.compatibleWP ) { #>'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$update_incompatible .= '<# } else if ( ! data.updateResponse.compatibleWP ) { #>'
$update_incompatible .= '<# } else if ( ! data.updateResponse.compatibleWP ) { #>';

And you would've gotten away with it too, if it hadn't been for that pesky semi-colon!

Copy link

github-actions bot commented Mar 4, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props joedolson, costdev.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link

github-actions bot commented Mar 4, 2024

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@joedolson joedolson closed this by deleting the head repository Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants