Plugins and Themes Auto-Updates: allow overriding of the HTML for the auto-update setting link. This will let plugins show better/specific information when they are overriding the auto-update settings, for example "Updates are managed by ... plugin".

Introduces: `theme_auto_update_setting_html`, `plugin_auto_update_setting_html`, and `theme_auto_update_setting_template` filters.

Props audrasjb, pbiron, azaozz.
Fixes #50280.

git-svn-id: https://develop.svn.wordpress.org/trunk@48077 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz
2020-06-17 23:58:15 +00:00
parent dbceb01b83
commit 8ca76ddd0a
3 changed files with 89 additions and 31 deletions
+47 -21
View File
@@ -549,6 +549,52 @@ if ( ! is_multisite() && $broken_themes ) {
</div><!-- .wrap -->
<?php
/**
* Returns the template for displaying the auto-update setting for a theme.
*
* @since 5.5.0
*
* @return string Template
*/
function wp_theme_auto_update_setting_template() {
$template = '
<p class="theme-autoupdate">
<# if ( data.autoupdate ) { #>
<a href="{{{ data.actions.autoupdate }}}" class="toggle-auto-update" data-slug="{{ data.id }}" data-wp-action="disable">
<span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span>
<span class="label">' . __( 'Disable auto-updates' ) . '</span>
</a>
<# } else { #>
<a href="{{{ data.actions.autoupdate }}}" class="toggle-auto-update" data-slug="{{ data.id }}" data-wp-action="enable">
<span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span>
<span class="label">' . __( 'Enable auto-updates' ) . '</span>
</a>
<# } #>
<# if ( data.hasUpdate ) { #>
<# if ( data.autoupdate ) { #>
<span class="auto-update-time">
<# } else { #>
<span class="auto-update-time hidden">
<# } #>
<br />' . wp_get_auto_update_message() . '</span>
<# } #>
<span class="auto-updates-error hidden"><p></p></span>
</p>
';
/**
* Filters the JavaScript template used in Backbone to display the auto-update setting for a theme (in the overlay).
*
* See {@see wp_prepare_themes_for_js()} for the properties of the `data` object.
*
* @since 5.5.0
*
* @param string $template The template for displaying the auto-update setting link.
*/
return apply_filters( 'theme_auto_update_setting_template', $template );
}
/*
* The tmpl-theme template is synchronized with PHP above!
*/
@@ -648,27 +694,7 @@ if ( ! is_multisite() && $broken_themes ) {
</p>
<# if ( data.actions.autoupdate ) { #>
<p class="theme-autoupdate">
<# if ( data.autoupdate ) { #>
<a href="{{{ data.actions.autoupdate }}}" class="toggle-auto-update" data-slug="{{ data.id }}" data-wp-action="disable">
<span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span>
<span class="label"><?php _e( 'Disable auto-updates' ); ?></span>
</a>
<# } else { #>
<a href="{{{ data.actions.autoupdate }}}" class="toggle-auto-update" data-slug="{{ data.id }}" data-wp-action="enable">
<span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span>
<span class="label"><?php _e( 'Enable auto-updates' ); ?></span>
</a>
<# } #>
<# if ( data.hasUpdate ) { #>
<# if ( data.autoupdate) { #>
<span class="auto-update-time"><br /><?php echo wp_get_auto_update_message(); ?></span>
<# } else { #>
<span class="auto-update-time hidden"><br /><?php echo wp_get_auto_update_message(); ?></span>
<# } #>
<# } #>
<span class="auto-updates-error hidden"><p></p></span>
</p>
<?php echo wp_theme_auto_update_setting_template(); ?>
<# } #>
<# if ( data.hasUpdate ) { #>