Make WordPress Core


Ignore:
Timestamp:
06/17/2020 11:58:15 PM (6 years ago)
Author:
azaozz
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/themes.php

    r48062 r48077  
    550550
    551551<?php
     552
     553/**
     554 * Returns the template for displaying the auto-update setting for a theme.
     555 *
     556 * @since 5.5.0
     557 *
     558 * @return string Template
     559 */
     560function wp_theme_auto_update_setting_template() {
     561    $template = '
     562        <p class="theme-autoupdate">
     563            <# if ( data.autoupdate ) { #>
     564                <a href="{{{ data.actions.autoupdate }}}" class="toggle-auto-update" data-slug="{{ data.id }}" data-wp-action="disable">
     565                    <span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span>
     566                    <span class="label">' . __( 'Disable auto-updates' ) . '</span>
     567                </a>
     568            <# } else { #>
     569                <a href="{{{ data.actions.autoupdate }}}" class="toggle-auto-update" data-slug="{{ data.id }}" data-wp-action="enable">
     570                    <span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span>
     571                    <span class="label">' . __( 'Enable auto-updates' ) . '</span>
     572                </a>
     573            <# } #>
     574            <# if ( data.hasUpdate ) { #>
     575                <# if ( data.autoupdate ) { #>
     576                    <span class="auto-update-time">
     577                <# } else { #>
     578                    <span class="auto-update-time hidden">
     579                <# } #>
     580                <br />' . wp_get_auto_update_message() . '</span>
     581            <# } #>
     582            <span class="auto-updates-error hidden"><p></p></span>
     583        </p>
     584    ';
     585
     586    /**
     587     * Filters the JavaScript template used in Backbone to display the auto-update setting for a theme (in the overlay).
     588     *
     589     * See {@see wp_prepare_themes_for_js()} for the properties of the `data` object.
     590     *
     591     * @since 5.5.0
     592     *
     593     * @param string $template The template for displaying the auto-update setting link.
     594     */
     595    return apply_filters( 'theme_auto_update_setting_template', $template );
     596}
     597
    552598/*
    553599 * The tmpl-theme template is synchronized with PHP above!
     
    649695
    650696                <# if ( data.actions.autoupdate ) { #>
    651                 <p class="theme-autoupdate">
    652                 <# if ( data.autoupdate ) { #>
    653                     <a href="{{{ data.actions.autoupdate }}}" class="toggle-auto-update" data-slug="{{ data.id }}" data-wp-action="disable">
    654                         <span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span>
    655                         <span class="label"><?php _e( 'Disable auto-updates' ); ?></span>
    656                     </a>
    657                 <# } else { #>
    658                     <a href="{{{ data.actions.autoupdate }}}" class="toggle-auto-update" data-slug="{{ data.id }}" data-wp-action="enable">
    659                         <span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span>
    660                         <span class="label"><?php _e( 'Enable auto-updates' ); ?></span>
    661                     </a>
    662                 <# } #>
    663                 <# if ( data.hasUpdate ) { #>
    664                     <# if ( data.autoupdate) { #>
    665                     <span class="auto-update-time"><br /><?php echo wp_get_auto_update_message(); ?></span>
    666                     <# } else { #>
    667                     <span class="auto-update-time hidden"><br /><?php echo wp_get_auto_update_message(); ?></span>
    668                     <# } #>
    669                 <# } #>
    670                     <span class="auto-updates-error hidden"><p></p></span>
    671                 </p>
     697                    <?php echo wp_theme_auto_update_setting_template(); ?>
    672698                <# } #>
    673699
Note: See TracChangeset for help on using the changeset viewer.