Make WordPress Core

Opened 10 years ago

Last modified 2 months ago

#34986 new enhancement

Add Upgrade Notice for Themes

Reported by: afragen's profile afragen Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Upgrade/Install Keywords: has-patch has-test-info has-screenshots dev-feedback
Focuses: Cc:

Description

There is upgrade notice for plugins that displays on the core update page if $transient->upgrade_notice is set in the pre_set_site_transient_update_{plugins|themes} filter, but there is no corresponding upgrade notice used or available for themes.

I propose adding a similar usage for themes as currently exists for plugins.

Use case, when theme upgrades are pending a notice of what changes, etc. will be available from the main update page.

Attachments (3)

34986.diff (1.4 KB) - added by afragen 10 years ago.
34986-test.png (26.6 KB) - added by oglekler 2 years ago.
test-34986.zip (591 bytes) - added by zunaid321 2 years ago.

Download all attachments as: .zip

Change History (32)

@afragen
10 years ago

#1 @afragen
10 years ago

  • Keywords has-patch added

#2 @johnbillion
10 years ago

  • Version trunk deleted

#3 @afragen
10 years ago

Any comments?

This ticket was mentioned in Slack in #core-upgrade-install by costdev. View the logs.


3 years ago

#5 @costdev
3 years ago

  • Milestone set to 6.3

#6 @costdev
3 years ago

  • Keywords needs-testing needs-testing-info added

@afragen Can you drop some testing info so that the patch can be tested? Thanks!

Additional props: @pbiron

#7 @afragen
3 years ago

  • Keywords needs-refresh added

This ticket was mentioned in PR #4238 on WordPress/wordpress-develop by @afragen.


3 years ago
#8

  • Keywords needs-refresh removed

Updated PR for adding an upgrade notice to theme updates in update-core.php as there is for plugin updates.

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

#9 @afragen
3 years ago

You can test the PR with the following plugin code. Obviously this would need to be added by the theme dev.

<?php
/**
 * Plugin Name: Test #34986
 * Description: Testing Trac Ticket #34986
 * Author: WP Core Contributors
 * Version: 0.1
 */

add_filter( 'site_transient_update_themes', 'add_upgrade_notice_34986', 20, 1 );

function add_upgrade_notice_34986($transient){
    $theme_slug = 'twentytwentythree';
    if ( isset($transient->response[$theme_slug])){
        $transient->response[$theme_slug]['upgrade_notice'] = 'Test of upgrade notice, #34986.';
    }

    return $transient;
}

To test, decrease the local version number of the Twenty Twenty Three theme so that it shows an update.

#10 @afragen
3 years ago

Above is for testing. I'm pretty sure all the dev needs to do is add a section == Upgrade Notice == to their readme.txt for the specific update and the readme parser in dot org will add the data to the update transient.

#11 @afragen
3 years ago

  • Keywords needs-testing-info removed

This ticket was mentioned in Slack in #core-upgrade-install by pbiron. View the logs.


3 years ago

@oglekler
2 years ago

#13 @oglekler
2 years ago

  • Keywords has-testing-info has-screenshots added

Patch (#comment:8) works as expected, screenshot is above.

We are in 9 days until the Beta 1, so, if this is going to trunk, it needs to move.

#14 @afragen
2 years ago

Corresponding ticket for plugins, #57939

#15 @zunaid321
2 years ago

Test Report

This report validates that the indicated patch addresses the issue.

Patch tested: https://patch-diff.githubusercontent.com/raw/WordPress/wordpress-develop/pull/4238.diff

Environment

  • OS: Windows 11 (22H2)
  • Web Server: nginx/1.23.4
  • PHP: 7.4.33
  • WordPress: 6.3-alpha-55505-src
  • Browser: Chrome Version 114.0.5735.110 (Official Build) (64-bit)
  • Theme: Twenty Twenty-Three

Testing Instructions

  • Applied Patch
  • Activated Attached Plugin - test-34986.zip
  • Lowered the theme version of Twenty Twenty Three Theme
  • ✅ The update notice showed up in the Updates Page for the Themes section.

Plugins Used

  • Attached: test-34986.zip

Screenshots

@zunaid321
2 years ago

#16 @peterwilsoncc
2 years ago

  • Milestone changed from 6.3 to Future Release

I asked the meta folks in Slack if the themes upgrade API endpoint included an upgrade notice and was told it doesn't.

Apparently the API only includes data in the stylesheet headers.

I think there has been discussion in the past about introducing one but it's premature to include the feature in core until it exists. I'm going to bump this to a future release so any action can be coordinated with the meta team.

#17 @afragen
2 years ago

@peterwilsoncc you're looking in the wrong place. Neither plugins or themes has this data from the API. The data exists as parsed data from the readme.txt file from the parser where it is included in the update data if it exists.

This ticket was mentioned in Slack in #meta by afragen. View the logs.


2 years ago

#19 @dd32
2 years ago

This would be pending https://meta.trac.wordpress.org/ticket/215 as readme.txt is not parsed for themes at all on WordPress.org. There's unlikely to be any movement on that (IMHO) until the Theme Directory is redesigned to accomodate it.

you're looking in the wrong place. Neither plugins or themes has this data from the API.

Plugins do offer this data via the API.

#20 follow-up: @afragen
2 years ago

Dion why are these or any of the APIs private. It makes things like this very difficult.

#21 @peterwilsoncc
2 years ago

The transient filter for testing in comment 9 shows the displayed data is intended to come from the API. If the theme update API adds support for upgrade notices then I'll happily add this feature to core, otherwise the code will go unused.

#22 in reply to: ↑ 20 @dd32
2 years ago

Replying to afragen:

Dion why are these or any of the APIs private. It makes things like this very difficult.

While it's not ideal it's private (There's no reason AFAIK, other than the breakage that would happen during migrating of it), there's nothing in there that's related to this ticket.

The fields are not parsed/stored/touched by the Theme Directory code-base, which is open-source. In the event it's added there, it's literally a 1 line addition to the update-check API to fetch that meta_value field too.

#23 @wordpressdotorg
7 months ago

  • Keywords has-test-info added; has-testing-info removed

#24 @SirLouen
7 months ago

  • Keywords dev-feedback added; needs-testing removed

I can see that thare are multiple test reports, but this is not progressing because of some Meta limitations for now. Since there is nothing to test, removing needs-testing tag.

#25 follow-up: @joostdekeijzer
3 months ago

Hi,

Based on the "Update URI" functionality for themes I'm developing an update solution for my clients custom themes and plugins.

It would be very helpful if I could use the upgrade_notice field not only for plugins but also for themes.

Can't PR https://github.com/WordPress/wordpress-develop/pull/4238 be applied and have the Meta team have their own planning?

The code won't be unused as it may be used by external developers like myself.

PS
Sorry for the spam. I did not know github comments are included here...

Last edited 3 months ago by joostdekeijzer (previous) (diff)

@joostdekeijzer commented on PR #4238:


3 months ago
#26

Hi Peter,

A couple of notes inline.

However, I can't see any indication of the upgrade_notice being supported for themes on the themes page or network themes page.

As I suggested in the Trac ticket: since there also is the "Update URI" functionality for themes it may be used by external developers like myself 😄

#27 in reply to: ↑ 25 @peterwilsoncc
3 months ago

Replying to joostdekeijzer:

Based on the "Update URI" functionality for themes I'm developing an update solution for my clients custom themes and plugins.

It would be very helpful if I could use the upgrade_notice field not only for plugins but also for themes.

Can't PR https://github.com/WordPress/wordpress-develop/pull/4238 be applied and have the Meta team have their own planning?

The order needs to go something like this:

  1. Theme Readme.txt spec supports Upgrade Notices (✅ -- have for quite a while)
  2. Meta team agrees on an endpoint structure for including the data
  3. Meta team plans to implement
  4. WordPress Core adds support for the endpoint value; Meta implement

The reason being that if something is added in WordPress Core prior to discussing the feature with the meta team; we committers would be making assumptions about the meta code base that we're unable to see.

The chances are that the field would end up being upgrade_notice but we still need to build the roads before attempting to use them.

PS
Sorry for the spam. I did not know github comments are included here...

No need to say sorry, even people who use trac daily sometimes get caught out by integration rules. Trust me, I know ;)

#28 @joostdekeijzer
3 months ago

Ok, I can follow that. But that does seem to put this minor change "on hold" for unknown time.

Regarding "building roads": developers using the UpdateURI field like myself may already have roads. In my API endpoint the upgrade_notice field is populated for both themes and plugins and when I apply the changes by Andy it works fine and as I would expect.

But following your steps: is the meta team aware of this (and perhaps other tickets)? Apart from https://meta.trac.wordpress.org/ticket/215 I could not find any open tickets referencing upgrade_notice or readme.txt. Their ticket https://meta.trac.wordpress.org/ticket/6897 was closed as invalid.

I really do hope it's possible to apply Andy's patch for the "3rd party" roads that external developers may have build.

#29 @joostdekeijzer
2 months ago

For those interested, a workaround below using javascript/jQuery

<?php
add_action( 'core_upgrade_preamble', function() {
  // !!! Currently WordPress does not support upgrade_notice for themes
  $themes = [];
  foreach ( get_theme_updates() as $stylesheet => $theme ) {
    if ( ! empty( $theme->update['upgrade_notice'] ) ) {
      $themes[ $stylesheet ] = wp_strip_all_tags( $theme->update['upgrade_notice'] );
    }
  }
  if ( ! empty( $themes ) ) {
    printf( '<script type="text/javascript">jQuery( function($) { $.each( %s, function( index, value ) { $( "#update-themes-table input[type=checkbox][value=" + index + "]" ).closest( "tr" ).find( "td.plugin-title p" ).append( "<br />" + value ); } ); } );</script>', json_encode( $themes, JSON_FORCE_OBJECT ) );
  }
} );

Note: See TracTickets for help on using tickets.