Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,24 +472,16 @@ 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";

return $url;
return "https://s.w.org/plugins/geopattern-icon/{$plugin->post_name}.svg";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,14 +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 ) );

// 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 ) );

// 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'] ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading