From affbf5d54a781ca9e82f332d564131c107997aa8 Mon Sep 17 00:00:00 2001 From: Muneeb Ashraf <58017595+muneeb-ashraf@users.noreply.github.com> Date: Tue, 10 Nov 2026 20:09:26 +0500 Subject: [PATCH 1/2] Plugin Directory: Drop the banner color used for generated icons Generated geopattern icons for plugins without an icon were colored from the average color of the plugin's banner, which needed the deprecated Jetpack Tonesque library and a banner download on every import. Few generated icons used it, so remove the banner color and let GeoPattern derive the color from the slug. - Remove Tools::get_image_average_color(). - Stop fetching the banner on import, and delete the stored assets_banners_color meta so it clears out on the next import. - Stop reading the meta in Template::get_geopattern_icon_url() and remove its unused $color parameter. - Remove the assets_banners_color meta registration and upload default. The geopattern-icon/_.svg rewrite rule and route stay, since cached API responses still point at those URLs. See https://meta.trac.wordpress.org/ticket/8115. Co-Authored-By: Claude Opus 5.5 --- .../api/class-plugin-fields.php | 6 ----- .../plugin-directory/class-template.php | 21 +++++++--------- .../plugins/plugin-directory/class-tools.php | 24 ------------------- .../plugin-directory/cli/class-import.php | 9 ++----- .../shortcodes/class-upload-handler.php | 1 - 5 files changed, 10 insertions(+), 51 deletions(-) diff --git a/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/class-plugin-fields.php b/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/class-plugin-fields.php index 11f0ba2308..77e800d1bf 100644 --- a/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/class-plugin-fields.php +++ b/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/class-plugin-fields.php @@ -76,12 +76,6 @@ private static function register_meta(): void { 'show_in_rest' => true, ] ); - register_meta( 'post', 'assets_banners_color', [ - 'description' => 'Fallback color for the plugin.', - 'single' => true, - 'show_in_rest' => true, - ] ); - register_meta( 'post', 'last_updated', [ 'description' => 'Date the plugin was last updated.', 'single' => true, diff --git a/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php b/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php index a960cb6752..a4d1939dd4 100644 --- a/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php +++ b/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php @@ -472,22 +472,17 @@ public static function get_plugin_icon( $post = null, $output = 'raw', $locale = /** * Retrieve the Geopattern SVG URL for a given plugin. + * + * The pattern color is derived from the slug. + * + * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. + * @return string The Geopattern SVG URL. */ - public static function get_geopattern_icon_url( $post = null, $color = null ) { + public static function get_geopattern_icon_url( $post = null ) { $plugin = get_post( $post ); - if ( is_null( $color ) ) { - $color = get_post_meta( $plugin->ID, 'assets_banners_color', true ); - } - - if ( strlen( $color ) === 6 && strspn( $color, 'abcdef0123456789' ) === 6 ) { - $color = "_{$color}"; - } else { - $color = ''; - } - - // This is a cached resource. The slug + color combine to form the cache buster. - $url = "https://s.w.org/plugins/geopattern-icon/{$plugin->post_name}{$color}.svg"; + // This is a cached resource. + $url = "https://s.w.org/plugins/geopattern-icon/{$plugin->post_name}.svg"; return $url; } diff --git a/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-tools.php b/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-tools.php index 8057a3e399..3722961372 100644 --- a/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-tools.php +++ b/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-tools.php @@ -13,30 +13,6 @@ */ class Tools { - /** - * Retrieve the average color of a specified image. - * - * This currently relies upon the Jetpack libraries. - * - * @static - * - * @param $file_location string URL or filepath of image. - * @return string|bool Average color as a hex value, False on failure. - */ - public static function get_image_average_color( $file_location ) { - if ( ! class_exists( 'Tonesque' ) && defined( 'JETPACK__PLUGIN_DIR' ) ) { - include JETPACK__PLUGIN_DIR . '/_inc/lib/tonesque.php'; - } - - if ( ! class_exists( 'Tonesque' ) ) { - return false; - } - - $tonesque = new \Tonesque( $file_location ); - - return $tonesque->color(); - } - /** * Returns the latest reviews of a specific plugin. * diff --git a/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php b/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php index 1abbec62b1..82ac844aeb 100644 --- a/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php +++ b/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php @@ -596,13 +596,8 @@ public function import_from_svn( $plugin_slug, $svn_changed_tags = array( 'trunk update_post_meta( $plugin->ID, 'assets_banners', wp_slash( $assets['banner'] ) ); update_post_meta( $plugin->ID, 'last_updated', wp_slash( $plugin->post_modified_gmt ) ); - // Calculate the 'plugin color' from the average color of the banner if provided. This is used for fallback icons. - $banner_average_color = ''; - if ( $first_banner = reset( $assets['banner'] ) ) { - // The Banners are not stored locally, which is why a URL is used here - $banner_average_color = Tools::get_image_average_color( Template::get_asset_url( $plugin, $first_banner, false /* no CDN */ ) ); - } - update_post_meta( $plugin->ID, 'assets_banners_color', wp_slash( $banner_average_color ) ); + // Fallback icons are no longer colored from the banner. Clear any stored color. + delete_post_meta( $plugin->ID, 'assets_banners_color' ); // Store the content of blueprint files, if they're available and valid. if ( isset( $assets['blueprint'] ) && count( $assets['blueprint'] ) > 0 ) { diff --git a/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php b/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php index cf00f504f8..da945662e1 100644 --- a/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php +++ b/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php @@ -584,7 +584,6 @@ public function process_upload( $for_plugin = 0 ) { 'assets_screenshots' => array(), 'assets_icons' => array(), 'assets_banners' => array(), - 'assets_banners_color' => false, 'support_threads' => 0, 'support_threads_resolved' => 0, 'downloads' => 0, From abfb78eff828f0bdd249fcdf0cbc227aadde474b Mon Sep 17 00:00:00 2001 From: Konstantin Obenland Date: Tue, 10 Nov 2026 15:35:00 -0600 Subject: [PATCH 2/2] Plugin Directory: Clear the banner color meta once at deploy, not on every import The stored color is dead data now, so deleting it on each import keeps a call in the import path forever and never reaches plugins that are not re-imported. Remove it once at deploy instead: wp eval 'delete_post_meta_by_key( "assets_banners_color" );' Also return the geopattern icon URL directly; the "cached resource" comment explained the color cache buster, which is gone. Co-Authored-By: Claude Opus 5.5 --- .../wp-content/plugins/plugin-directory/class-template.php | 5 +---- .../wp-content/plugins/plugin-directory/cli/class-import.php | 3 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php b/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php index a4d1939dd4..308ff13770 100644 --- a/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php +++ b/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php @@ -481,10 +481,7 @@ public static function get_plugin_icon( $post = null, $output = 'raw', $locale = public static function get_geopattern_icon_url( $post = null ) { $plugin = get_post( $post ); - // This is a cached resource. - $url = "https://s.w.org/plugins/geopattern-icon/{$plugin->post_name}.svg"; - - return $url; + return "https://s.w.org/plugins/geopattern-icon/{$plugin->post_name}.svg"; } /** diff --git a/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php b/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php index 82ac844aeb..dc905c280d 100644 --- a/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php +++ b/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php @@ -596,9 +596,6 @@ public function import_from_svn( $plugin_slug, $svn_changed_tags = array( 'trunk update_post_meta( $plugin->ID, 'assets_banners', wp_slash( $assets['banner'] ) ); update_post_meta( $plugin->ID, 'last_updated', wp_slash( $plugin->post_modified_gmt ) ); - // Fallback icons are no longer colored from the banner. Clear any stored color. - delete_post_meta( $plugin->ID, 'assets_banners_color' ); - // Store the content of blueprint files, if they're available and valid. if ( isset( $assets['blueprint'] ) && count( $assets['blueprint'] ) > 0 ) { update_post_meta( $plugin->ID, 'assets_blueprints', wp_slash( $assets['blueprint'] ) );