Created
October 4, 2017 22:30
Revisions
-
bradyvercher created this gist
Oct 4, 2017 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ <?php /** * Register plugin icons. * * WordPress 4.9 introduced icons in the list table on the Manage Plugins * screen. The icons are pulled from the W.org update API. If an icon isn't * available, a generic plugin Dashicon is shown instead. * * @param array $value Plugin update data. * @return array */ add_filter( 'site_transient_update_plugins', function( $value ) { $vendor_slug = 'example'; // Unique vendor slug. $plugin_file = 'example/example.php'; // Relative path to the main plugin file from the plugins directory. $plugin_icon = 'https://example.com/plugin-icon.png'; // URL to the plugin icon. $icons = array( '1x' => '', '2x' => '', 'default' => $plugin_icon, ); $plugin_slug = dirname( $plugin_file ); if ( isset( $value->no_update[ $plugin_file ] ) ) { $value->no_update[ $plugin_file ]->icons = $icons; } elseif ( isset( $value->response[ $plugin_file ] ) ) { $value->response[ $plugin_file ]->icons = $icons; } else { $data = new stdClass; $data->id = $vendor_slug . '/' . $plugin_slug; $data->slug = $plugin_slug; $data->plugin = $plugin_file; $data->icons = $icons; $value->no_update[ $plugin_file ] = $data; } return $value; } );