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

View File

@@ -1041,6 +1041,8 @@ class WP_Plugins_List_Table extends WP_List_Table {
echo "<td class='column-auto-updates{$extra_classes}'>";
$html = array();
if ( in_array( $plugin_file, $auto_updates, true ) ) {
$text = __( 'Disable auto-updates' );
$action = 'disable';
@@ -1060,26 +1062,41 @@ class WP_Plugins_List_Table extends WP_List_Table {
$url = add_query_arg( $query_args, 'plugins.php' );
printf(
$html[] = sprintf(
'<a href="%s" class="toggle-auto-update" data-wp-action="%s">',
wp_nonce_url( $url, 'updates' ),
$action
);
echo '<span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span>';
echo '<span class="label">' . $text . '</span>';
echo '</a>';
$html[] = '<span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span>';
$html[] = '<span class="label">' . $text . '</span>';
$html[] = '</a>';
$available_updates = get_site_transient( 'update_plugins' );
if ( isset( $available_updates->response[ $plugin_file ] ) ) {
printf(
$html[] = sprintf(
'<div class="auto-update-time%s">%s</div>',
$time_class,
wp_get_auto_update_message()
);
}
$html = implode( '', $html );
/**
* Filters the HTML of the auto-updates setting for each plugin in the Plugins list table.
*
* @since 5.5.0
*
* @param string $html The HTML of the plugin's auto-update column content,
* including toggle auto-update action links and time to next update.
* @param string $plugin_file Path to the plugin file relative to the plugins directory.
* @param array $plugin_data An array of plugin data.
*/
echo apply_filters( 'plugin_auto_update_setting_html', $html, $plugin_file, $plugin_data );
echo '<div class="inline notice error hidden"><p></p></div>';
echo '</td>';